[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: full backup of repository

From: Mark Shead <sheadm_at_optimalinternet.com>
Date: 2005-11-16 14:43:10 CET

> If I want to backup my repository to burn on a CD can I just tar my
complete repository directory?

You should probably use svndump to put it in a text file. Here is a
perl script that I use to:
1. Dump the repository to a text file.
2. Name it with the date as the extension.
3. Zip it up.
4. Copy it to another server
5. Copy it back from the other server
6. Create a temporary repository
8. Restore the backup into the repository
9. Checkout from the temp repository
10. Clean everything up

I run this as a nightly cron job, so if it has any problems they show up
in my email. If you just want to make a back up, you'll probably only
need the first few steps, so you can cut out anything that you don't


#!/usr/bin/perl -w

my $svn_repo = "/var/svn";
my $backup_dir = "/home/admin/backups";
my $next_backup_file = "repo_backup-";
my $tmp_dir = "/home/admin/tmp";
my $backup_server = "";
my $backup_server_login = "backup";

$next_backup_file = $next_backup_file . `date +%Y%m%d-%H%M`;
chomp $next_backup_file;
my $youngest = `svnlook youngest $svn_repo`;
chomp $youngest;

my $dump_command = "svnadmin -q dump $svn_repo >
$backup_dir/$next_backup_file ";
print "\nDumping Subversion repo $svn_repo to $next_backup_file...\n";
print `$dump_command`;
print "Backing up through revision $youngest... \n";
print "\nCompressing dump file...\n";
print `gzip -9 $backup_dir/$next_backup_file\n`;
chomp $next_backup_file;
my $zipped_file = $backup_dir . "/" . $next_backup_file . ".gz";
print "\nCreated $zipped_file\n";
print `scp $zipped_file
print "\n$next_backup_file.gz transferred to backup server\n";

#Test Backup
print "\n---------------------------------------\n";
print "Testing Backup";
print "\n---------------------------------------\n";
print "Downloading $next_backup_file.gz from $backup_server\n";
print `scp
print "Unzipping $next_backup_file.gz\n";
print `gunzip $tmp_dir/$next_backup_file.gz`;
print "Creating test repository\n";
print `svnadmin create $tmp_dir/test_repo`;
print "Loading repository\n";
print `svnadmin -q load $tmp_dir/test_repo <
print "Checking out repository\n";
print `svn -q co file://$tmp_dir/test_repo $tmp_dir/test_checkout`;
print "Cleaning up\n";
print `rm -f $tmp_dir/$next_backup_file`;
print `rm -rf $tmp_dir/test_checkout`;
print `rm -rf $tmp_dir/test_repo`;

To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Nov 16 14:45:49 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.