hotcopy Description
This subcommand makes a full “hot” backup of your repository, including all hooks, configuration files, and, of course, database files. If you pass the
--clean-logs
option, svnadminwill perform a hot copy of your repository, and then remove unused Berkeley DB logs from the original repository. You can run this command at any time and make a safe copy of the repository, regardless of whether other processes are using the repository.
svnadmin hotcopy --help
Make a hot copy of a repository.
If --incremental is passed, data which already exists at the destination
is not copied again. Incremental mode is implemented for FSFS repositories.Valid options:
--clean-logs : remove redundant Berkeley DB log files
from source repository [Berkeley DB]
--incremental : dump or hotcopy incrementall // 增量
http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.hotcopy.html
用法
svnadmin hotcopy <Depot_Path> <Backup_Path > --clean-logs --incremental
示例
cd /var/svn/svn_dir #切到版本库上层目录 svnlook youngest QA_script #查看目录下的QA_script 库的最新版本号 svnadmin hotcopy /var/svn/svn_dir/QA_script /var/svn/svn_dir/backup --clean-logs --incremental #使用hotcopy进行备份,当首次使用过后已有备份库后,源库继续有提交,可重复使用此命令进行增量备份 svnlook youngest backup #查看版本备份库的最新版本号
注意
- svnadmin hotcopy 后,目标路径会生成一个同步的版本库,访问时只需要切换目录名即可。
- 备份目录在启用之前切记不可修改。否则后续备份增量版本时会有报错。
- 此方法相当于一切全量拷贝,包括配置和数据。也无需产生中间文件。
- <Backup_Path > 可以是他机目录,带用户ip 。当故障发生时,可马上切换到备份机(已安装svn)上启服务。
- 使用svnlook youngest 来查看当前库的最新版本号
双机热备思路
备份机 --设置备份目录
root@ubuntu:/public/backup# chmod +777 /public/backup/
vi /etc/exports
加上 /public/backup/ 作为共享目录
sudo service nfs-kernel-server restart
版本机 --定时备份到备份目录
把备份机目录mount 到版本机:
mount -t nfs -o rw 172.0.11.245:/public/backup /backup
设置定时任务:crontab -e
00 00 * * * /backup/backup.sh QA_script
30 00 * * * /backup/backup.sh Auto_script
backup.sh
#!/bin/sh Depot=$1 Date=`date +%Y%m%d%H%M` Log=${Depot}_${Date}.log Depot_Path="/var/svn/svn_dir" Back_Path="/backup" mkdir -p /public/backup if [ -z ${Depot} ]; then echo "error:no depot : usage:./xx.sh Depot_name" exit -1 fi echo "depot : ${Depot_Path}/${Depot} " >>/backup/log/${Log} 2>&1 echo "version:" >>/backup/log/${Log} 2>&1 svnlook youngest ${Depot_Path}/${Depot} >>/backup/log/${Log} 2>&1 echo "sync ing....." >>/backup/log/${Log} 2>&1 svnadmin hotcopy ${Depot_Path}/${Depot} ${Back_Path}/${Depot}_bak --clean-logs --incremental >>/backup/log/${Log} 2>&1 echo "sync done." >>/backup/log/${Log} 2>&1 echo "depot : ${Back_Path}/${Depot}_bak " >>/backup/log/${Log} 2>&1 echo "version:" >>/backup/log/${Log} 2>&1 svnlook youngest ${Back_Path}/${Depot}_bak >>/backup/log/${Log} 2>&1 ~
crontab -e
30 00 * * * /backup/backup.sh Auto_script
验证:
备份机:
- $ apt-get install subversion
- $ apt-get install libapache2-svn
- svnserve -d -r /public/backup
- 使用备份机目录访验证 svn://172.0.xx.xx/QA_script_bak
- 如果认证有问题,检查下是不是版本库中con/svnserve.conf 里配置的用户文件是相对路径。
No Leanote account? Sign up now.