Linux
每天增量備份 SVN 儲存庫?(作業系統 = UNIX)
問題的第一部分如何進行 SVN 儲存庫的增量備份?執行此操作的命令是什麼……以及如何自動執行此操作(OS + UNIX)
如果您想自己做,請查看“svnlook youngest”和“svnadmin dump –incremental -r $ {STARTREV}: $ {ENDREV}”命令。
我在腳本下方粘貼了用於對我的 SVN 儲存庫進行完整和增量轉儲的腳本,它們將上次備份的修訂版和日期儲存在 /home/svn/var 的子目錄中。首先進行完整轉儲,然後根據需要進行盡可能多的增量轉儲。
完整的 SVN 轉儲腳本:
#!/bin/sh # Full dump of all subversion repositories # make sure to get the subversion environment variables . /etc/profile.d/subversion.sh # path to subversion binaries SVN_BINPATH=${SVN_HOME}/bin # path to parent of all repositories to be dumped SVN_REPPATH=/opt/svn/repositories # destination directory for backup files DUMP_DIR=/backup/svn # status directory SVN_VAR=/home/svn/var DATETIME=`date +%Y%m%d` for rep in ${SVN_REPPATH}/*; do TSTAMP=`date +%s` CURR_REV=`${SVN_BINPATH}/svnlook youngest ${rep}` REP_BASE=`basename $rep` echo "**********************************************************" echo "`date --rfc-2822` - Full back up - ${rep} : " echo " current revision ${CURR_REV}" echo DUMPFILE=${DUMP_DIR}/${REP_BASE}-${DATETIME}.dmp ${SVN_BINPATH}/svnadmin --quiet dump $rep > ${DUMPFILE} echo ${TSTAMP} > ${SVN_VAR}/status/dates/${REP_BASE}.dt echo ${CURR_REV} > ${SVN_VAR}/status/revisions/${REP_BASE}.rev bzip2 --compress --best ${DUMPFILE} done echo echo `ls -hl ${DUMP_DIR}/*.bz2`
增量 SVN 轉儲腳本:
#!/bin/sh # Incremental dump of all subversion repositories # make sure to get the subversion environment variables . /etc/profile.d/subversion.sh # path to subversion binaries SVN_BINPATH=${SVN_HOME}/bin # path to parent of all repositories to be dumped SVN_REPPATH=/opt/svn/repositories # destination directory for backup files DUMP_DIR=/backup/svn # status directory SVN_VAR=/home/svn/var DATETIME=`date +%Y%m%d` for rep in ${SVN_REPPATH}/*; do TSTAMP=`date +%s` CURR_REV=`${SVN_BINPATH}/svnlook youngest ${rep}` REP_BASE=`basename $rep` if [ -e ${SVN_VAR}/status/dates/${REP_BASE}.dt ] ; then REP_LAST_BK_TSTAMP=`cat ${SVN_VAR}/status/dates/${REP_BASE}.dt` REP_LAST_BK_REV=`cat ${SVN_VAR}/status/revisions/${REP_BASE}.rev` else REP_LAST_BK_TSTAMP=0 REP_LAST_BK_REV=0 fi if [ ${CURR_REV} -gt ${REP_LAST_BK_REV} ] ; then echo "**********************************************************" echo "`date --rfc-2822` - Incremental back up ${rep} : " echo " oldest revision ${REP_LAST_BK_REV} - newest revision ${CURR_REV}" echo DUMPFILE=${DUMP_DIR}/${REP_BASE}-${DATETIME}-${REP_LAST_BK_REV}-${CURR_REV}.dmp ${SVN_BINPATH}/svnadmin --quiet dump $rep --incremental -r${REP_LAST_BK_REV}:${CURR_REV}> ${DUMPFILE} echo ${TSTAMP} > ${SVN_VAR}/status/dates/${REP_BASE}.dt echo ${CURR_REV} > ${SVN_VAR}/status/revisions/${REP_BASE}.rev bzip2 --compress --best ${DUMPFILE} fi done echo echo `ls -hl ${DUMP_DIR}/*.bz2`
希望這可以幫助。