Automatic backup of SVN repository and scheduled deletion on Windows

Source: Internet
Author: User

The following script is a backup strategy in Windows SVN, using the Hotcopy method

Programme one:

1. Create a fullbackup script first; fullbackup.bat

the installation directory for Echo Offrem subversionSetSvn_home="D:\Program Files\subversion\bin"rem Parent directory for all repositorySetsvn_root=D:\svnserverrem the backup directorySetbackup_svn_root=D:\backupsvn\fullbackupSetbackup_directory=%backup_svn_root%\%date:~0,4%%date:~5,2%%date:~8,2%Setlog_file=fullbackup-%date:~0,4%%date:~5,2%%date:~8,2%. Logifexist%backup_directory% rd/s/q%backup_directory%echo Create backup directory%backup_directory%>>%svn_root%\%log_file%mkdir%backup_directory%mkdir%backup_directory%\confxcopy%svn_root%\conf%backup_directory%\confecho%svn_root%\conf successfully backed up to%backup_directory%\conf>>%svn_root%\%log_file%REM verifies that the directory is a repository, and if yes, take out the name backup for/R%svn_root%%%iinch(.) Do@if exist"%%i\conf\svnserve.conf"Hotcopy.bat"%%~fi"%%~ni

2. When creating a hot standby script, Hotcopy.bat

@echo is backing up the repository%1... @%svn_home%\svnadmin hotcopy%1 %backup_directory%\%2@ echo Version library %1 was successfully backed up to%2! Echo Version library %1 was successfully backed up to%backup_directory%\%2>>%svn_root%\%log_file%

3. Periodically delete backups from one months ago, Delsvn.bat

echo Onrem need to delete the SVN backup directorySetbackupsvn_root="D:\backupsvn\fullbackup"REM is removing the backup repository 30 days ago ... Forfiles/P%backupsvn_root%/s/m */D- -/C"cmd/c del/s/q @path"rem Delete empty folder dir/ad/b/s%backupsvn_root% |sort/r >F:\kill.txt for/F"tokens=*"%%iinch(F:\kill.txt) Do Rd"%%i"del f:\kill.txt

4. Place the three scripts in a directory and click Fullbackup.bat to generate the yymmdd/repository in the backup directory. But unfortunately I put this fullbackup in the Task Scheduler to execute, the following one hotcopy.bat always failed to execute, I have given up.

Scenario Two:

Write a backup script Hotcopy.bat

Svnadmin hotcopy D:\Repositories\root f:\svn\fullbackup\%date:~0,4%%date:~5,2 %%date:~8,2

Put to the task plan execution is OK, and then combined with Delsvn.bat can achieve the purpose of regular deletion.

Automatic backup of SVN repository and scheduled deletion on Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.