SVN backup script

Source: Internet
Author: User
Tags rsync

SVN backup is typically used in three different ways:
1) svnadmin dump
2) svnadmin hotcopy
3) Svnsync.

Note that SVN backup is not recommended for normal file copy (unless you pause the library when you back up), such as the Copy command, the rsync command.
I used the rsync command to do incremental and full backup, in the quarterly backup check audit, found that the majority of the backup library is not available, so it is best to use the functionality provided by SVN itself for backup.

pros and cons analysis
============== 
The first type of Svnadmin dump is the official recommended backup method, with the advantage of being flexible enough to have a full backup or incremental backup, and to provide a version recovery mechanism.
The disadvantage is that if the version is larger, such as the number of versions increases to tens of thousands of, hundreds of thousands of, then the process of dump will be very slow, backup time, recovery more time-consuming, not conducive to rapid disaster recovery.
It is recommended that you use this backup method when the number of versions is smaller.
the second Svnadmin hotcopy original design objective is not to be used for backup, only a full-volume copy can not be incremental backup;
The advantage is that the backup process is fast and disaster recovery is fast, and if the SVN service is already set up on the backup machine and does not even need to be restored, simply configure it to switch to the backup repository.
The disadvantage is: more expensive hard disk, need to have a large hard disk support (my backup machine has 1TB space, hehe).
The Third kind of svnsync is actually making 2 mirror libraries, and when one is broken, you can quickly switch to another. However, this feature must be supported on svn1.4 versions.
The advantages are as follows: when making 2 mirror libraries, we play the role of two-machine real-time backup;
The downside is that when used as 2 mirror libraries, there is no way to "completely abandon today's changes and revert to what they were like last night"; while daily backup as a normal backup mechanism, the operation is more troublesome than the first 2 methods.



#!/usr/bin/perl-w

My $svn _repos= "/opt/svn/repos";

My $backup _dir= "/opt/backup/svn/";

My $next _backup_file = "Weekly_fully_backup." ' Date +%y%m%d ';


$youngest = ' Svnlook youngest $svn _repos ';

Chomp $youngest;


Print "Backing up to revision $youngest \ n";

My $svnadmin _cmd= "Svnadmin dump--revision 0: $youngest $svn _repos > $backup _dir/$next _backup_file";

' $svnadmin _cmd ';

Open (LOG, "> $backup _dir/last_backed_up"); #记录备份的版本号

Print LOG $youngest;

Close LOG;

#如果想节约空间, then execute the following compression script

Print "compressing dump file...\n";

print ' gzip-g $backup _dir/$next _backup_file ';


This article is from "Ghost" blog, please make sure to keep this source http://fangwei009.blog.51cto.com/5234706/1633020

SVN 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.