首页  编辑  

每天定时备份MySQL和Redmine, Git等的脚本

Tags: /计算机文档/软件应用技巧/   Date Created:
中小型的企业,使用MySQL,Redmine,Git的,定时备份并保留最近一个月的批处理脚本,简单粗暴有效,稳定可靠:
设定一个计划任务,每天晚上3:00运行下面的脚本即可:

backup.bat,内容如下:

@echo off
set today=%date:~0,4%-%date:~5,2%-%date:~8,2%
C:\Bitnami\redmine-3.4.6-0\mysql\bin\mysqldump -uroot -ppassword --lock-all-tables --all-databases > mysql_%today%.sql
"C:\Program Files\7-Zip\7z.exe" a mysql_%today%.zip mysql_%today%.sql
del mysql_%today%.sql

"C:\Program Files\7-Zip\7z.exe" a -r git_%today%.zip C:\inetpub\wwwroot\Bonobo.Git.Server\App_Data\Repositories
"C:\Program Files\7-Zip\7z.exe" a -r redmine_files_%today%.zip C:\Bitnami\redmine-3.4.6-0\apps\redmine\htdocs\files

REM 删除30天前的备份
forfiles /m mysql_*.zip /d -30 /c "cmd /c del @file"
forfiles /m git_*.zip /d -30 /c "cmd /c del @file"
forfiles /m redmine_files_*.zip /d -30 /c "cmd /c del @file"