svn dump 全自动备份脚本

转载 2016年05月30日 11:16:11


原文:http://carywu.blog.51cto.com/13185/207571
最近要给美国的SVN服务器做升级,由于这台服务器有一定年份了,在本公司也算是个三朝元老,保存了多少code啊!。为了保险起见,老板将迁移的工作郑重的交到我的手上。在欣欣然的同时也颤抖着。
不过还好我已经对其轻车熟路,在新的服务器上安装好apache和subversion软件后,开始着手备份与迁移了。
由于旧服务器版本太低,没有svnsync的功能,考虑再三,我选择使用了svnadmin dump去做备份。
可是有一个问题了,每个库的版本都有几万了,然后服务器上有十几个库,我可没耐心一个个输入svnadmin dump去备份它们,那会让我觉得长夜漫漫,难于睡眠!
管理员的最高境界就是花力气去懒惰,我很向往这个境界。所以,我花了些时间写了个shell,就让系统自己去干这些事情吧!

shell功能:
只需要大家修改源库所在的目录,和备份存放的目录就可以了。
第一次运行会全部备份,然后以后每次运行会增量备份。
所以,恢复的时候,先恢复全部备份,然后依次按照日期恢复增量备份即可。


#!/bin/sh

#########################################################
# this script is used for svn repository backup
# written: carywu
# date: 2008/11/21
#########################################################

###################################
# mail address for status updates
#  - This is used to email you a status report
###################################
MAILADDR=carywu@yahoo.cn

###################################
# backup directory,please change it
# - This is the path to the backup directory
###################################
BACKUPDIR=/svnroot/svnback

###################################
# svn repository directory, please change it.
# - This is the path to the directory you want to archive
###################################
SVNDIR=/svnroot/repository

###################################
# HOSTNAME and project list
#  - This is also used for reporting
###################################
ProjectLst=$BACKUPDIR/projectlist.txt

###################################
# svn backup log path and date
#  - This is used to log result
###################################
LogFile=$BACKUPDIR/svnback.log
DATE=`date +%Y%m%d-%T`
###################################
# svn command path
# - This is the path to the directory you want to archive
###################################
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# our actual rsyncing function
do_accounting()
{
        echo " " >> $LogFile
        echo " " >> $LogFile
        echo "###########################" >> $LogFile
        echo "$DATE" >> $LogFile
        echo "###########################" >> $LogFile
        cd $BackDir
}

do_svndump()
{
   PROJECTLIST=`cat $ProjectLst`
   cd $SVNDIR
   for project in $PROJECTLIST
          do
          echo "begin to dump $project databases" >> $LogFile
                if [ ! -f $BACKUPDIR/$project.dump ]
                then
                YOUNGEST=`svnlook youngest $project`
                svnadmin dump $project > $BACKUPDIR/$project.dump
                echo "OK,dump file successfully!!"
                echo "$YOUNGEST" > $BACKUPDIR/$project.youngest
                else
                        echo "$project.dump existed,will do increatment job" >> $LogFile
                        if [ ! -f $BACKUPDIR/$project.youngest ]
                        then
                        echo "error, no youngest check!" >> $LogFile
                        else
                                PREVYOUNGEST=`cat $BACKUPDIR/$project.youngest`
                                NEWYOUNGEST=`svnlook youngest $project`
                                if [ $PREVYOUNGEST -eq $NEWYOUNGEST ]
                                then
                                        echo " no database updated!" >> $LogFile
                                else
                                        LASTYOUNGEST=`expr $PREVYOUNGEST + 1`
                                        echo "last youngest is $LASTYOUNGEST" >> $LogFile
                                        svnadmin dump $project --revision $LASTYOUNGEST:$NEWYOUNGEST --incremental > $BACKUPDIR/$project-$LASTYOUNGET-$NEWYOUNGEST.$DATE
                                        echo "$NEWYOUNGEST" > $BACKUPDIR/$project.youngest
                                fi
                        fi
  fi
        done
}

# our post rsync accounting function
do_mail()
{
   mail $MAILADDR -s svn-back_log < $LogFile
}
# some error handling and/or run our backup and accounting
do_accounting && do_svndump && do_mail


#########################################################
# this script is used for svn repository backup
# written: carywu
# date: 2008/11/21
#########################################################

###################################
# mail address for status updates
#  - This is used to email you a status report
###################################
MAILADDR=carywu@yahoo.cn

###################################
# backup directory,please change it
# - This is the path to the backup directory
###################################
BACKUPDIR=/svnroot/svnback

###################################
# svn repository directory, please change it.
# - This is the path to the directory you want to archive
###################################
SVNDIR=/svnroot/repository

###################################
# HOSTNAME and project list
#  - This is also used for reporting
###################################
ProjectLst=$BACKUPDIR/projectlist.txt

###################################
# svn backup log path and date
#  - This is used to log result
###################################
LogFile=$BACKUPDIR/svnback.log
DATE=`date +%Y%m%d-%T`
###################################
# svn command path
# - This is the path to the directory you want to archive
###################################
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# our actual rsyncing function
do_accounting()
{
        echo " " >> $LogFile
        echo " " >> $LogFile
        echo "###########################" >> $LogFile
        echo "$DATE" >> $LogFile
        echo "###########################" >> $LogFile
        cd $BackDir
}

do_svndump()
{
   PROJECTLIST=`cat $ProjectLst`
   cd $SVNDIR
   for project in $PROJECTLIST
          do
          echo "begin to dump $project databases" >> $LogFile
                if [ ! -f $BACKUPDIR/$project.dump ]
                then
                YOUNGEST=`svnlook youngest $project`
                svnadmin dump $project > $BACKUPDIR/$project.dump
                echo "OK,dump file successfully!!"
                echo "$YOUNGEST" > $BACKUPDIR/$project.youngest
                else
                        echo "$project.dump existed,will do increatment job" >> $LogFile
                        if [ ! -f $BACKUPDIR/$project.youngest ]
                        then
                        echo "error, no youngest check!" >> $LogFile
                        else
                                PREVYOUNGEST=`cat $BACKUPDIR/$project.youngest`
                                NEWYOUNGEST=`svnlook youngest $project`
                                if [ $PREVYOUNGEST -eq $NEWYOUNGEST ]
                                then
                                        echo " no database updated!" >> $LogFile
                                else
                                        LASTYOUNGEST=`expr $PREVYOUNGEST + 1`
                                        echo "last youngest is $LASTYOUNGEST" >> $LogFile
                                        svnadmin dump $project --revision $LASTYOUNGEST:$NEWYOUNGEST --incremental > $BACKUPDIR/$project-$LASTYOUNGET-$NEWYOUNGEST.$DATE
                                        echo "$NEWYOUNGEST" > $BACKUPDIR/$project.youngest
                                fi
                        fi
  fi
        done
}

# our post rsync accounting function
do_mail()
{
   mail $MAILADDR -s svn-back_log < $LogFile
}
# some error handling and/or run our backup and accounting
do_accounting && do_svndump && do_mail



相关文章推荐

SVN使用svnadmin dump进行备份时报“拒绝访问”错误

svnadmin dump进行备份时报“拒绝访问”错误的解决方法,网上查阅的大多数都是说文件系统错误,自己遇到的情况与网上的不同,就把这个问题和解决方法分析给大家吧

MySQL 5.5 DBA工具 多进程dump 多进程load 多进程备份还原 python 脚本

mysqldump 目前只支持但线程dump,物理备份innodb因为额ibdata又有天生的缺陷,例如将一个实例中的某个库导入到另一个实例中,就比较麻烦了。 所以写了这套脚本。 适用场景: 1...
  • ylqmf
  • ylqmf
  • 2012-09-18 22:11
  • 6843

Windows下SVN备份脚本

Windows下SVN备份脚本

svn备份脚本 svn备份 svn脚本

SVN版本库备份操作脚本

  • 2011-07-11 22:14
  • 20KB
  • 下载

svn配置库全量备份脚本

  • 2010-04-21 16:04
  • 791B
  • 下载

备份脚本(svn、oracle、配置文件)

#!/usr/bin/env python # -*- coding: cp936 -*- ''' Created on 2011-10-2 @author: caojj ''' ...

svn自动备份脚本.zip

  • 2010-07-23 08:54
  • 19KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)