SVN backup script

Source: Internet
Author: User

Always use this script to back up, although the script body is not original, but from the Internet because it can not be run also made some changes, the first two days to see someone asked about the SVN backup problem, and today the script to solve the problem can not be recycled to backup multiple configuration library. We hope to help you. Also thank you for providing the main script body.
My backup strategy is one months a full backup, an incremental backup once a week, and daily incremental backup, in the window task set timed, set up and then no tube, plus a layer of insurance is to regularly move backup files to another machine storage.
(i) Full backup with two files Hotcopy.bat and final execution files Fullbackup.bat
1) Hotcopy.bat
@echo backing up the version library%1 ...
REM @%svn_home%\bin\svnadmin hotcopy%1%backup_directory%\%2
@%svn_home%\svnadmin hotcopy%1%backup_directory%\%2
@echo Version library%1 was successfully backed up to%2!


2) Fullbackup.bat
echo off
installation directory for REM subversion
REM Set svn_home= "F:\Program files\subversion"
Set svn_home= "F:\Program files\collabnet Subversion Server"
REM Parent directory for all repository
Set SVN_ROOT=G:\SVN
The list of REM backups
Set Backup_svn_root=h:\svnrootbak
Set backup_directory=%backup_svn_root%\%date:~0,10%

If exist%backup_directory% goto Checkback
echo Create backup directory%backup_directory%>>%svn_root%/fullbackup.log
mkdir%backup_directory%
REM verifies that the directory is a repository, and if yes, take out the name backup
FOR/R%svn_root%%%i in (.) do @if exist "%%i\conf\svnserve.conf" Hotcopy.bat "%%~fi"%%~ni
Goto END
: Checkback
Echo backup directory%backup_directory% already exists, please empty it.
Goto END
: End


(ii) Incremental backup with three files, Dump.bat, final file Svndump.bat, and configuration library name configuration projectlist.conf
1) Dump.bat
@ECHO OFF
REM Call format: Dump Project library name
If "%1" = = "" Goto No_args
Set project=%1
If not exist%rar_store%\%project% mkdir%rar_store%\%project%
CD%rar_store%\%project%
SET lower=0
SET upper=0

@echo Project Library%project%2...>>%log_path%\%project%_log.txt
%svn_look% youngest%svn_reporoot%\%project%>%log_path%\a.tmp
@echo Project Library%project%3...>>%log_path%\%project%_log.txt
@FOR/F%%D In (%log_path%\a.tmp) do set upper=%%d
If%upper%==0 goto:n_exit
If not exist%log_path%\%project%_last_revision.txt Goto:bakup
REM takes out the version number after the last backup and does +1 processing (note that this algorithm is not validated in the 98 system)
@FOR/F%%C in (%log_path%\%project%_last_revision.txt) do @set lower=%%c
@set/A lower=%lower%+1
REM does not need backup, then jump ends
IF%lower% GTR%upper% Goto:n_exit

: Bakup
SET filename=%project%_%lower%_%upper%
@ECHO start backing up the project library:%project%, generating the file =%filename%
%svn_admin% dump%svn_reporoot%\%project%-R%lower%:head--incremental >%filename%.dmp
rem%rar_cmd% a-df%project%_%upper%.rar%
REM Ready to write backup log information
IF%lower% GTR 0 Goto:writenote
@ECHO------2-----%date% >>%log_path%\%project%_log.txt
@echo--3-------Add backup file%project%_%upper%.rar, from [%lower%] to [%upper%] >>%log_path%\%project%_log.txt
Goto:complete

: Writenote
@ECHO%date% >>%log_path%\%project%_log.txt
@echo--4------Add incremental backup file%project%_%upper%.rar, from [%lower%] to [%upper%] >>%log_path%\%project%_log.txt

: Complete
REM The following line is used to copy the backup file onto the mapped drive
REM Copy%project%.rar%rar_store%\%project%\
Move%filename%.dmp%rar_store%\%project%\
Del%log_path%\a.tmp
@echo%upper% >%log_path%\%project%_last_revision.txt

: N_exit
@echo Project Library%project% processing ends ...>>%log_path%\%project%_log.txt
@CD:
@exit/b
: No_args
@ECHO on
@echo "Call method correctly: Dump Project library name"


2) Svndump.bat
echo off
installation directory and execution files for REM subversion
Set svn_home= "F:\Program files\collabnet Subversion Server"
Set Svn_admin=%svn_home%\svnadmin.exe
Set Svn_look=%svn_home%\svnlook.exe
REM Configuration library Repository root directory
Set SVN_REPOROOT=G:\SVN
REM Compression command
Set rar_cmd= "E:\progra~1\winrar\winrar"
REM Incremental backup file storage path
Set rar_store= "H:\svnincrementW"
The REM log and last backup revision number are stored in the file directory, and the following is the same directory as the incremental backup script directory
Set LOG_PATH=G:\BACKUP\INCREMENTW

@echo Project Library%project% processing 1...>>%log_path%\%project%_log.txt
REM reads the project library list file and ignores it; the beginning of the line
for/f "eol=;"%%C in (projectlist.conf) does call G:\backup\incrementW\dump.bat%%C


3) projectlist.conf
;**************************************************
; 01. Project1 Development Library
; Update frequency: High
;**************************************************
PROJECT1
;**************************************************
; 02. Note Information can be written here
;**************************************************
PROJECT2
PROJECT3
PROJECT4
PROJECT5

SVN backup script

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.