SVN 项目备份脚本

Linux安全运维 (3828) 2023-12-16 14:51:19

1. 完全备份

remote_full_backup_doc.bat(192.168.0.226——每周二、四、六的00:00执行,192.168.3.200——每周三、五的00:00执行)
svnadmin hotcopy E:\Repositories\Doc Z:\svnhotcopyfullbackup\Doc\Doc-hc.%date:~0,4%年%date:~5,2%月%date:~8,2%日

remote_full_backup_project.bat(192.168.0.226——每周二、四、六的1:30执行,192.168.3.200——每周三、五的1:30执行)
svnadmin hotcopy E:\Repositories\Project Z:\svnhotcopyfullbackup\Project\Project-hc.%date:~0,4%年%date:~5,2%月%date:~8,2%日

remote_full_backup_projectnew.bat(192.168.0.226——每周二、四、六的00:30执行,192.168.3.200——每周三、五的00:30执行)
svnadmin hotcopy E:\Repositories\ProjectNew Z:\svnhotcopyfullbackup\ProjectNew\ProjectNew-hc.%date:~0,4%年%date:~5,2%月%date:~8,2%日

2. 增量备份

backup_delta_to_158.bat(192.168.0.226——每天的23:30执行)
copy /Y E:\delta\Doc\* \\192.168.0.158\data\svnrootbak\delta\Doc\*
copy /Y E:\delta\Project\* \\192.168.0.158\data\svnrootbak\delta\Project\*
copy /Y E:\delta\ProjectNew\* \\192.168.0.158\data\svnrootbak\delta\ProjectNew\*
echo 删除7天之前的文件
forfiles /p "E:\delta\Doc" /s /m *.* /d -7 /c "cmd /c del @path"
forfiles /p "E:\delta\Project" /s /m *.* /d -7 /c "cmd /c del @path"
forfiles /p "E:\delta\ProjectNew" /s /m *.* /d -7 /c "cmd /c del @path"
forfiles /p "Z:\svndeltabackup\Doc" /s /m *.* /d -7 /c "cmd /c del @path" 
forfiles /p "Z:\svndeltabackup\Project" /s /m *.* /d -7 /c "cmd /c del @path"
forfiles /p "Z:\svndeltabackup\ProjectNew" /s /m *.* /d -7 /c "cmd /c del @path"

3. 删除过期全量备份

remote_del_Doc_2_days_ago.bat(192.168.0.226——每天的10:00执行)
set Today=%date:~0,4%%date:~5,2%%date:~8,2%
set /a DelDate=%Today%-2
set DelDirName=Z:\svnhotcopyfullbackup\Doc\Doc-hc.%DelDate:~0,4%年%DelDate:~4,2%月%DelDate:~6,2%日
rd /S /Q %DelDirName%

remote_del_Project_2_days_ago.bat(192.168.0.226——每天的10:10执行)
set Today=%date:~0,4%%date:~5,2%%date:~8,2%
set /a DelDate=%Today%-2
set DelDirName=Z:\svnhotcopyfullbackup\Project\Project-hc.%DelDate:~0,4%年%DelDate:~4,2%月%DelDate:~6,2%日
rd /S /Q %DelDirName%

remote_del_ProjectNew_2_days_ago.bat(192.168.0.226——每天的10:05执行)
set Today=%date:~0,4%%date:~5,2%%date:~8,2%
set /a DelDate=%Today%-2
set DelDirName=Z:\svnhotcopyfullbackup\ProjectNew\ProjectNew-hc.%DelDate:~0,4%年%DelDate:~4,2%月%DelDate:~6,2%日
rd /S /Q %DelDirName%
THE END

发表评论