如何每晚备份我的Subversion代码库?我想每晚都将代码库转储到网络驱动器上。
请查阅《svnbook》中关于如何从版本库中提取转储的仓库维护章节。然后使用定时服务(例如at
或cron
,或Windows操作系统中非常好用的任务计划程序,具体取决于您服务器的系统)每晚执行转储。完成。
#!/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