http://blog.leanote.com/post/gua_l/hotcopy
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
http://blog.leanote.com/post/gua_l/hotcopy
svnadmin hotcopy <Depot_Path> <Backup_Path > --clean-logs --incremental
cd /var/svn/svn_dir
svnlook youngest backup
svnlook youngest QA_script
svnadmin hotcopy /var/svn/svn_dir/QA_script /var/svn/svn_dir/backup --clean-logs --incremental
svnlook youngest backup
svnadmin hotcopy 后,目标路径会生成一个同步的版本库,访问时只需要切换目录名即可。
备份目录在启用之前切记不可修改。否则后续备份增量版本时会有报错。
此方法相当于一切全量拷贝,包括配置和数据。也无需产生中间文件。
可以是他机目录,带用户 ip 。当故障发生时,可马上切换到备份机(已安装 svn)上启服务。
使用 svnlook youngest 来查看当前库的最新版本号
chmod +777 /public/backup/
vi /etc/exports
##加上 /public/backup/ 作为共享目录
sudo service nfs-kernel-server restart
把备份机目录 mount 到版本机:
mount -t nfs -o rw 172.0.xx.xxxx:/public/backup /backup
设置定时任务:
crontab -e
00 00 * * * /backup/backup.sh QA_script
30 00 * * * /backup/backup.sh Auto_script
#!/bin/sh
Depot=$1
Date=`date +%Y%m%d%H%M`
Log=${Depot}_${Date}.log
Depot_Path="/var/svn/svn_dir"
Back_Path="/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
使用备份机目录访验证 svn://172.0.xx.xx/QA_script_bak
如果认证有问题,检查下是不是版本库中 con/svnserve.conf 里配置的用户文件是相对路径。