前提条件:
主:10.11.100.205
从:10.11.100.50
源目录:http://10.11.100.205/svn/rep-ops
目标目录:http://10.11.100.50/svn/rep-ops
1.在从机建立空目录
mkdir -pv /yc/svn/rep-ops
svnadmin create /yc/svn/rep-ops
cd /yc/svn/rep-ops/hooks
cp pre-revprop-change.tmpl pre-revprop-change
把pre-revprop-change文件最后一行的exit 1改成exit 0,并配置700权限。
2.把主机各版本库下的conf目录覆盖至从机各版本库下
scp -r /yc/svn/rep-ops/conf root@10.11.100.50:/yc/svn/rep-ops/
3.从库执行复制版本0的属性(此时需要输入root以及svn账号密码)
svnsync sync file:///yc/svn/rep-ops
4.配置主机实现代码提交后自动同步更新到从机
cd /yc/svn/rep-ops/hooks
cp post-commit.tmpl post-commit
删除文件最后的3行,增加如下内容
svnsync sync --non-interactive http://10.11.100.50/yc/svn/rep-ops --username admin --password xiaoke
*由于不同的版本库需要同步,使用统一的/权限用户admin
5.不同的版本库配置如上
从:10.11.100.50
源目录:http://10.11.100.205/svn/rep-ops
目标目录:http://10.11.100.50/svn/rep-ops
1.在从机建立空目录
mkdir -pv /yc/svn/rep-ops
svnadmin create /yc/svn/rep-ops
cd /yc/svn/rep-ops/hooks
cp pre-revprop-change.tmpl pre-revprop-change
把pre-revprop-change文件最后一行的exit 1改成exit 0,并配置700权限。
2.把主机各版本库下的conf目录覆盖至从机各版本库下
scp -r /yc/svn/rep-ops/conf root@10.11.100.50:/yc/svn/rep-ops/
3.从库执行复制版本0的属性(此时需要输入root以及svn账号密码)
svnsync sync file:///yc/svn/rep-ops
4.配置主机实现代码提交后自动同步更新到从机
cd /yc/svn/rep-ops/hooks
cp post-commit.tmpl post-commit
删除文件最后的3行,增加如下内容
svnsync sync --non-interactive http://10.11.100.50/yc/svn/rep-ops --username admin --password xiaoke
*由于不同的版本库需要同步,使用统一的/权限用户admin
5.不同的版本库配置如上
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由于使用源码包进行安装,所以使用绝对路径。**