mysql全备份批处理命令

1.mysql全备份

复制以下代码, 保存为.bat文件
@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
D:/wamp64/bin/mysql/mysql5.7.14/bin/mysqldump --opt -u root --password=123456 database > E:/Database/backupDB_all/test_%Ymd%.sql
@echo on
远程备份
@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
C:/wamp64/bin/mysql/mysql5.7.14/bin/mysqldump --opt -h 127.0.0.1 -u root --password="123456" database > E:/Database/backupDB_all/test_%Ymd%.sql
@echo on

2.删除3天前的文件

forfiles /p "C:\BackupDB\database" /d -3 /c "cmd /c echo deleting @file ... && del /q @path" 

你可能感兴趣的:(bat)