SVN Dump Incremental backup script

Source: Internet
Author: User

SVN incremental backup script,

Environment: System, CENTOS6.5,SVN version 1.6.11,httpd apache/2.2.15 (Unix)

APR 1.3.9, Apr-util 1.3.9, all for Yum compilation


Some common commands

SVN ls-v/opt/svn/snn View svn directory file list

SVN--version View SVN version

Svnadmin CREATE/OPT/SVN/SNN Create an SVN repository

SVN import/etc/issue FILE:///OPT/SVN/SNN/1-m T import data


First script, full backup

#/bin/bash## svn dump full standby and incremental backup scripts       (full script, environment) filedir=/opt/svn/snn# SVN file directory baupdir=/tmp/svn_back_data#svn backup save address SVNCONF=/TMP/SVN_BACK_CONF#SVN configuration Save address version=/tmp/svn_back_veri# An incremental backup must use the version number #  if the directory does not exist then create it [ ! -d  $BAUPDIR  ] && mkdir $ baupdir[ ! -d  $SVNCONF  ] && mkdir  $SVNCONF [ ! -d $ version ] && mkdir  $VERSION # First must stop HTTP and SVN service/sbin/service httpd stop  &>/dev/null/sbin/service svnserve stop  &>/dev/null/usr/bin/svnadmin  dump  $FILEDIR  >  $BAUPDIR/' date +%f_%t '. firstsvn    &>/ dev/null/usr/bin/svnlook youngest  $FILEDIR  >  $VERSION/frist.txt &>/dev/null  /bin/cp -i /opt/svn/authfile/conf/*  $SVNCONF/bin/cp -i /etc/httpd/conf.d/ subversion.conf  $SVNCONF # Backup complete and restart/sbin/service svnserve start  &>/dev/null/sbin/service httpd start     &>/dev/null


Second script, incremental backup

#/bin/bash### svn dump full standby and incremental backup scripts        (incremental script)   Two scripts separate write filedir=/opt/ SVN/SNN#SVN file directory baupdir=/tmp/svn_back_data#svn backup save address SVNCONF=/TMP/SVN_BACK_CONF#SVN configuration Save address Version=/tmp/svn_back_ veri# Incremental backup must use version number # First you must stop HTTP and SVN service/sbin/service httpd stop &>/dev/null/sbin/service  svnserve stop  &>/dev/nullfor i in {1..6};d ofristnum= ' cat $ Version/frist.txt ' #初始值  let fristnum= $FRISTNUM +1# initial value plus 1 to start backing up data, the recovery will be error/usr/bin/svnlook youngest   $FILEDIR  >  $VERSION/two.txtincrement= ' cat  $VERSION/two.txt '/usr/bin/svnadmin dump  --incremental -r  $FRISTNUM: $INCREMENT   $FILEDIR  >  $BAUPDIR/svn_increment_$ isleep 3/usr/bin/svnlook youngest  $FILEDIR  > /tmp/svn_back_veri/frist.txt# backup complete and reboot/ sbin/service svnserve start  &>/dev/null/sbin/service httpd start     &>/Dev/nullsleep 24hdone 



#备份的数据 test time to control yourself, Bash-x xx.sh view the compilation process

-rw-r--r--. 1 root root 686827436 Jul 12:17 2016-07-29_12:16:43.firstsvn

-rw-r--r--. 1 root root 2320 Jul 12:20 svn_increment_1

#备份无数据时大小直接为零, can be directly ignored when recovering

-rw-r--r--. 1 root root 0 Jul 12:21 svn_increment_2

-rw-r--r--. 1 root root 973 Jul 12:21 Svn_increment_3

-rw-r--r--. 1 root root 1422 Jul 12:22 Svn_increment_4

-rw-r--r--. 1 root root 1871 Jul 12:22 svn_increment_5


#恢复如下

#恢复时从第一个开始复制比如: First from full backup, then first, second, third, and so on

Svnadmin CREATE/OPT/SVN/SNN first set up a new warehouse, of course, the path is arbitrarily defined

Svnadmin load/opt/svn/snn/< 2016-07-29_12:16:43.FIRSTSVN

Svnadmin load/opt/svn/snn/< Svn_increment_1

Svnadmin load/opt/svn/snn/< Svn_increment_3

Svnadmin load/opt/svn/snn/< Svn_increment_4

Svnadmin load/opt/svn/snn/< Svn_increment_5


Third script: Full backup only

#/bin/bash## SVN script, this script can only be fully prepared every Saturday 1 o'clock in the morning full backup 0 * * 6/bin/bash/tmp/xx.sh filedir=/opt/svn/snnbackupdir=/tmp/svn_back_ datasvnconf=/tmp/svn_back_conf# If the directory does not exist then create it [!-D $BACKUPDIR] && mkdir $BACKUPDIR [!-D $SVNCONF] && m Kdir $SVNCONF # SVN data full script svnadmin hotcopy restore the directory file in turn write/usr/bin/svnadmin hotcopy $FILEDIR/' Date +%f_%t '. Svnback $ backupdir# Package The copied configuration file/bin/tar zcfp $SVNCONF/' Date +%f_%h-%m '. tar.gz/etc/httpd/conf.d/subversion.conf/opt/svn/ authfile/conf/*--xattrs &>/dev/null


The third way to recover a script

Svnadmin hotcopy Warehouse Name full path < backup file full path

This article is from the "Xiong" blog, make sure to keep this source http://xiong51.blog.51cto.com/5239058/1831723

SVN Dump Incremental backup script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.