未名Q

此生若能得幸福安稳,谁又愿颠沛流离。

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: 订阅 订阅 :: 管理 ::
 1 @echo off
 2 rem 先要检查 echo %date:~0,10% 的输出内容,不能含斜划线。
 3 rem 7za.exe 7za.dll 7zxa.dll 的 %path% 中已存在。 
 4 
 5 :publicVariable
 6 set backupDir=C:\backups
 7 set dumpDir=C:\Downloads
 8 
 9 :bakMySQL-abc
10 set dbName=abc
11 set dbUser=abc_user
12 set dbPassword=3BwcmyCXagT2
13 del /q /f %backupDir%\db_%dbName%_*.7z
14 mysqldump -hlocalhost -P3306 -u%dbUser% -p%dbPassword% --events --routines --triggers --databases %dbName% > %dumpDir%\db_%dbName%_%date:~0,10%.sql
15 7za.exe a -t7z %backupDir%\db_%dbName%_%date:~0,10%.7z %dumpDir%\db_%dbName%_%date:~0,10%.sql
16 del /q /f %dumpDir%\db_%dbName%_%date:~0,10%.sql
17 
18 :bakFiles-abc
19 set sourceName=abc
20 set sourceDir=C:\abc
21 del /q /f %backupDir%\file_%sourceName%_*.7z
22 7za.exe a -t7z %backupDir%\file_%sourceName%_%date:~0,10%.7z %sourceDir%
23 
24 exit

 auotBackupFiles.7z

 

posted on 2023-04-08 00:03  未名Q  阅读(38)  评论(0编辑  收藏  举报