SVN轮滚备份脚本
svn轮滚备份脚本
说明: 保留7个备份,backup.1最新备份, backup.7最旧备份。
#!/bin/bash ################################### ### author: www.ttlsa.com ### ### QQ群: 39514058 ### ### E-mail: service@ttlsa.com ### ################################### 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
本文由主机测评网发布,不代表主机测评网立场,转载联系作者并注明出处:https://zhuji.jb51.net/yunwei/8303.html