如何我可以做SVN存储库一步一步备份….我想备份本身的存储库….我不想备份它作为文件夹….
步骤1创build运行该命令的脚本或batch file
svnadmin dump REPOS_PATH > backupfile
svnadmin是svn自带的程序,它将在bin文件夹中
备份文件是存储库将被转储到的文件
REPOS_PATH是存储库的位置
请参阅http://svnbook.red-bean.com/en/1.1/re31.html了解更多详情
步骤2.运行脚本/batch file以testing备份。
步骤3.通过运行命令testing备份是否工作
svnadmin load test_path < backupfile
现在尝试在test_path中创build的存储库,以确保它可以正常工作 – 它应该和作为奖金它应该与更新版本的svn。
而已。
你可以在同一台机器上或类似的机器上恢复(例如,windows – > windows)。 如果你想从Windows恢复到Linux(比如说),那么你需要转储和加载存储库。 您仍然需要复制目录的其余部分。
build议使用rsync来复制所有的东西(但是你必须停止服务器总是得到一个好的备份),或使用svnsync这是一个很好的增量备份工具的SVN。 (你仍然必须复制钩子和configuration,以及 – 我rsync的那些和svnsync回购)
以下脚本可以保存为:svnbackup.sh
#!/bin/bash appname=`basename $0` # # Set some defaults # increment=100 start="" default_history_file="last_saved" history_file="" dumpfilepath="." dumpfilename="dumpfile" verbose=false sshopts="" identity="" # # Function to explain how to use the program # function usage () { echo echo "$appname [-h]" echo "$appname [-v] [-i increment] [-s start_rev] [--scp remote] [--identity ssh-key] [--ssh-opts ssh options] [--history-file file] [--out-dir directory name] [--compress (gzip|bzip2)] [--file-name dumpfile-base-name] svn_repository_path" cat - <<EOF This script dumps a subversion repository to a series of compressed files. It uses a local file to remember the last changeset dumped so the script can be used to generate files for backups. Using the --scp option, the backup files can be generated on one machine and copied to a backup server once dumped. -v -- Verbose mode -i increment -- How many revisions to include in each dump file. --file-name base -- Base name for dump files, defaults to "dumpfile". -s start_rev -- First revision to dump. --scp remote -- Location for remote backups. Files are transfered via scp, then removed from the local directory. --identity -- Identity file for scp transfer --ssh-opts -- options to use for scp --history-file -- path and filename of historyfile to use --out-dir -- path where svn dump files should be written, defaults to "." --compress -- compression method (gzip or bzip2, defaults to bzip2) EOF echo echo "Example:" echo " $appname -v -i 100 --scp user@backupserver:/backups/svn /svn/Project" echo exit $1 } compress_app="bzip2" compress_ext="bzip2" # # Process arguments # while [ $# -gt 0 ] do opt="$1" case "$opt" in -h) usage 0;; -i) increment=$2; shift;; -s) start=$2; shift;; --scp) dest="$2"; shift;; --identity) identity="$2"; shift;; --ssh-opts) sshopts="$2"; shift;; --history-file) history_file="$2"; shift;; --out-dir) dumpfilepath="$2"; shift;; --file-name) dumpfilename="$2"; shift;; -v) verbose=true;; --compress) case "$2" in bzip2|bz|bzip) compress_app="bzip2"; compress_ext="bzip2";; gzip|gz) compress_app="gzip"; compress_ext="gz";; esac; shift;; *) break;; esac shift done repository="$1" if [ -z "$repository" ] then echo "Failed: Repository argument required" usage 1 fi if [ -z "$history_file" ] then history_file="$dumpfilepath/$default_history_file" fi if [ "x${start}" = "x" ] then # if [ -s $history_file ] #Blocco Rinominato per NON Tenere Conto Last_saved # then # loop_first=`cat $history_file` # else # loop_first=0 # fi loop_first=0 else loop_first=$start fi youngest=`svnlook youngest "$repository"` $verbose && echo "Backing up: $repository" $verbose && echo " From: $loop_first" $verbose && echo " To: $youngest" if [ "$dest" != "" ] then $verbose && echo " Dest: $dest" fi if [ "$identity" != "" ] ; then $verbose && echo " Identity: $identity" fi if [ "$sshopts" != "" ] ; then $verbose && echo " ssh opts: $sshopts" fi $verbose && echo "Hist. file: $history_file" $verbose && echo "Chunk size: $increment" # # Function to do the backup for one set of revisions # function backup_revs () { typeset first=$1 typeset last=$2 typeset repo=$3 if [ "$first" != "0" ] then incremental="--incremental" fi repo_name=`basename "$repo"` dumpfile="$dumpfilepath/${dumpfilename}-${repo_name}-${first}-${last}.${compress_ext}" $verbose && echo -n "Dumping ${first}:${last} ..." svnadmin dump -q "$repo" $incremental --revision ${first}:${last} \ | "$compress_app" > "$dumpfile" RC=$? $verbose && echo if [ $RC -ne 0 ] then rm -f "$dumpfile" return $RC fi $verbose && echo "Created $dumpfile" if [ "$dest" != "" ] then if [ -z "$identity" ] ; then scp $sshopts "$dumpfile" "$dest" else scp $sshopts -i $identity "$dumpfile" "$dest" fi RC=$? rm -f "$dumpfile" fi return $RC } # # Do the incremental dumps # if [[ $youngest -eq $loop_first ]] then $verbose && echo "No new changesets to dump" exit 0 fi let loop_last=($loop_first + $increment) if [[ $loop_first -ne 0 ]] then let loop_first=($loop_first + 1) fi while [[ $loop_first -le $youngest ]] do if [ $loop_last -lt $youngest ] then # A full "increment" backup_revs $loop_first $loop_last "$repository" || exit 1 #echo $loop_last > $history_file else # In case the last few revs do not make up a full "increment" backup_revs $loop_first $youngest "$repository" || exit 1 #echo $youngest > $history_file fi let loop_first=($loop_last + 1) let loop_last=($loop_last + $increment) done exit 0
只需创build一个svn目录的副本。
编辑:
如前所述 – 您需要先停止svn服务器。
你需要停止Apache和SSH,如果你使用它们来访问你的回购。