svn使用dump和hotcopy进行脚本备份

[root@svn shell]# cat repolist 
dev-arc
dev-bm
dev-crm
dev-pay
dev-pm
dev-portal
dev-risk
hr
product
qa
rep-ops
[root@svn shell]# cat svnbackup.sh 
#!/bin/bash
rm -rf /yc/backup/dump/* &> /dev/null
rm -rf /yc/backup/hotcopy/* &> /dev/null
DATE=$(date +%Y%m%d)
#######################dump backup###############################
for i in `cat /shell/repolist`
do
/yc/usr/local/subversion/bin/svnadmin dump /yc/svn/$i  > /yc/backup/dump/$i-$DATE.dump.gz
done
if [ $? -eq 0 ];then
    echo "$DATE /yc/usr/local/subversion/bin/svnadmin dump full backup successful." >> /var/log/svnbackup.log
else
    echo "$DATE /yc/usr/local/subversion/bin/svnadmin dump full backup failed." >> /var/log/svnbackup.log
fi
ssh root@10.11.100.205 "mkdir /yc/svn/backup/dump/$DATE"
scp -r /yc/backup/dump/* root@10.11.100.205:/yc/svn/backup/dump/$DATE &> /dev/null
if [ $? -eq 0 ];then
    echo "$DATE Transfer svn dump backup to 10.11.100.205 successful." >> /var/log/svnbackup.log 
else
    echo "$DATE Transfer svn dump backup to 10.11.100.205 failed." >> /var/log/svnbackup.log 
fi
#######################hotcopy backup###############################
for i in `cat /shell/repolist`
do
/yc/usr/local/subversion/bin/svnadmin hotcopy  /yc/svn/$i /yc/backup/hotcopy/$i 
done
if [ $? -eq 0 ];then
    echo "$DATE /yc/usr/local/subversion/bin/svnadmin hotcopy full backup successful." >> /var/log/svnbackup.log
else
    echo "$DATE /yc/usr/local/subversion/bin/svnadmin hotcopy full backup failed" >> /var/log/svnbackup.log
fi
ssh root@10.11.100.205 "mkdir /yc/svn/backup/hotcopy/$DATE"
scp -r /yc/backup/hotcopy/* root@10.11.100.205:/yc/svn/backup/hotcopy/$DATE/ &> /dev/null
if [ $? -eq 0 ];then
    echo "$DATE Transfer svn hotcopy backup to 10.11.100.205 successful." >> /var/log/svnbackup.log 
else
    echo "$DATE Transfer svn hotcopy backup to 10.11.100.205 failed." >> /var/log/svnbackup.log 
fi
注释:
**subversion由于使用源码包进行安装,所以使用绝对路径。**
posted @ 2016-05-04 11:58  xkops  阅读(1804)  评论(0编辑  收藏  举报