SVN轮滚备份脚本

svn轮滚备份脚本 说明: 保留7个备份,backup.1最新备份, backup.7最旧备份。
#!/bin/bash
###################################
### author: www.ttlsa.com ###
### QQ群: 39514058 ###
### E-mail: [email protected] ###
###################################
SVN_REPOS=(/www/svn/web/*.ttlsa.com)
BACKUP_BASE_DIR=/www/repo_backup
backup_rotate() {
if cd $1
then
for num in 7 6 5 4 3 2 1
do
old=`expr $num + 1`
if [ -d backup.${num} ]
then
if [ -d backup.${old} ]
then
rm -rf backup.${old} && mv backup.${num} backup.${old}
else
mv backup.${num} backup.${old}
fi
fi
done
else
echo "change BACKUP_DIR error!"
exit 1
fi
}
for REPO in "${SVN_REPOS[@]}"
do
REPONAME=`/usr/bin/basename $REPO`
BACKUP_DIR="$BACKUP_BASE_DIR/$REPONAME"
[ -d "$BACKUP_DIR" ] || mkdir -p $BACKUP_DIR
cd $BACKUP_DIR && backup_rotate $BACKUP_DIR
/usr/bin/svnadmin hotcopy $REPO $BACKUP_DIR/backup.1
done
转载请注明出处:http://www.ttlsa.com/html/1261.html

你可能感兴趣的:(shell,SVN,SVN,备份,subversion,svnadmin,svn备份,hotcopy,hotcopy,轮滚)