使用 svnsync 做 svn 的代码备份
1. 备份主机操作
cd /data/svnvim pre-revprop-change#!/bin/shUSER="$3"if [ "$USER"="svnsync" ];thenexit 0fiecho "Only the svnsync user may change revision properties as this is a read-only, mirror repository." >&2exit 1chmod +x pre-revprop-change
cd /data/svnvim start-commit#!/bin/shUSER="$2"if [ "$USER"="svnsync" ]; thenexit 0fiecho "Only the svnsync user may commit new revisions as this is a read-only, mirror repository." >&2exit 1chmod +x start-commit
cd /data/svncat > authz <<EOF[/]svnsync=rwEOFcat > passwd <<EOF[users]svnsync=svnsyncEOFcat > svnserve.conf <<EOF[general]anon-access = noneauth-access = writepassword-db = /data/svn/passwdauthz-db = /data/svn/authzEOFsvnadmin create SVN_REPOcp pre-revprop-change start-commit SVN_REPO/hookscp svnserver.conf SVN_REPO/conf/
2. svn 主机
# 初始化svnsync initialize svn://192.168.2.22/test file:///data/svn/ttt --username=svnsync --password=svnsync# svnsync initialize URL_MIRROR_REPO URL_MASTER_REPO --username=svnsync --password=svnsyncpassword# 同步svnsync synchronize svn://192.168.2.22/test --username=svnsync --password=svnsync# svnsync synchronize URL_TO_MIRROR_REPO --username=svnsync --password=passwd
创建一个钩子,自动同步
vim hooks/post-commit#!/bin/bash/usr/bin/svnsync sync svn://192.168.2.22/test --username=svnsync --password=svnsync &exit 0chmod +x hooks/post-commit
