1 svn完全备份脚本的书写
vi /data/myscripts/fullsvnbackup 内容如下:
- #!/bin/bash
- #author:liuhaiqing
- #date:20110719
- riqi=$(date +'%Y%m%d')
- backupdir=/data/svnback
- mkdir -p $backupdir/$riqi
- old=$(svnlook youngest /data/svn/repos/test/)
- echo "$old" >/tmp/oldnumber
- svnadmin dump /data/svn/repos/test --revision 0:$old --incremental >$backupdir/$riqi/0-"$old"svn.bak
2 svn增量备份脚本书写
vi /data/myscripts/zengliangsvnbackup
- #!/bin/sh
- riqi=$(date +'%Y%m%d')
- backupdir=/data/svnback
- mkdir -p $backupdir/$riqi
- old=$(cat /tmp/oldnumber)
- new=$(svnlook youngest /data/svn/repos/test/)
- if [ $old = $new ]
- then
- echo "svn don't need backup"
- else
- b=$(expr 1 + $old)
- echo "$new" >/tmp/oldnumber
- svnadmin dump /data/svn/repos/test --revision $b:$new --incremental >$backupdir/$riqi/"$b"-"$new"svn.bak
- fi
3 增加计划任务
- 0 3 * * * sh /data/myscripts/fullsvnbackup
- 0 8-20/2 * * * sh /data/myscripts/zenglingsvnbackup
4 svn还原
恢复顺序从低版本逐个恢复到高版本;即,先恢复最近的一次完整备份,然后恢复紧挨着这个文件的增量备份
- cd /data/svn/repos/
- svnadmin create test2
- svnadmin load test2 </data/svnback/20110719/0-1112svn.bak
- svnadmin load test2 </data/svnback/20110719/1113-1113svn.bak
- chown -R daemon.daemon test2
至此恢复成功
5 附上脚本,以免复制粘贴出问题