Auto-Back Up of Subversion Repository

纵饮孤独 提交于 2019-12-21 09:30:04

问题


How do I backup my Subversion Repository nightly? I have a network drive I'd like to dump the repository to on a nightly basis.


回答1:


Check out the Repository Maintenance chapter in The Book on how to pull a dump out of the repository. Then use a timed service (at or cron for example, or the very nice task scheduler in Windows OS's, depends on your server's system) to execute the dump nightly. Done.




回答2:


The SVN book has a section on Repository Backup.

The svnadmin hotcopy command allows you to safely backup a live repository.

The svnsync command is another possibility.




回答3:


I just wrote a short script to do the job. The first run does a full backup, every further run does just an increment over the last commits during last backup. the backup files will get the number of the last revision to track the procedure.

Set up the right settings for

WORKDIR=path to where this script resists

SVN_REPO_LOCATION=path to where the repository resists on hd

BACKUPDIR=path to where the backup should goes to

SVN_LOACTION=root location which you use in your svn command

and add the script to cronjob, thats it.

#!/bin/bash
WORKDIR=/home/user/svnbackup
SVN_REPO_LOCATION=/opt/svn
BACKUPDIR=./backup
SVN_LOACTION=https://mysvn.server.com/svn

cd $WORKDIR;
CURRENT_VERSION=`svn info $SVN_LOACTION | grep Revision | awk '{print $2}'`
LAST_VERSION=`cat svn.version 2>/dev/null`
mkdir -p $BACKUPDIR;
if [ "$LAST_VERSION" = "" ]
then
        echo fullbackup;
        svnadmin dump -q $SVN_REPO_LOCATION > $BACKUPDIR/svn_backup_$CURRENT_VERSION.dump;
        echo $CURRENT_VERSION > svn.version;
else
        if [ "$LAST_VERSION" == "$CURRENT_VERSION" ]
        then
                echo backup not necessary;
        else
                echo incremental;
                svnadmin dump -q $SVN_REPO_LOCATION -r$LAST_VERSION:$CURRENT_VERSION --incremental  > $BACKUPDIR/svn_backup_$CURRENT_VERSION.dump;
                echo $CURRENT_VERSION > svn.version;
        fi
fi


来源:https://stackoverflow.com/questions/2366421/auto-back-up-of-subversion-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!