[[email protected] shell]# cat repolist
dev-arc
dev-bm
dev-crm
dev-pay
dev-pm
dev-portal
dev-risk
hr
product
qa
rep-ops
[[email protected] 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 [email protected] "mkdir /yc/svn/backup/dump/$DATE"
scp -r /yc/backup/dump/* [email protected]:/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 [email protected] "mkdir /yc/svn/backup/hotcopy/$DATE"
scp -r /yc/backup/hotcopy/* [email protected]:/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由于使用源码包进行安装,所以使用绝对路径。**