Wednesday, February 07, 2007

Backups of Subversion repositories

Here's the scenario: you are running a Subversion server and like all serious geeks, you want it backed up. This here post will show you how I do it for Windows and *nix _simultaneously_. I'm making the following assumptions:

Path typeWindows*nix
the subversion repositories are locatedd:\svnrepo/home/svn
the backup root folderd:\backups/home/backups
the subversion CLI(in the path)(in the path)


The first script performs not only a hotcopy backup of a repository (provided as the first parameter), but also first erases whatever backup might have been there (with a special provision for the very first time around) and creates a "dump" of the repository's contents, along with a final clean-up to save space. The reason we are keeping a dump over the contents of the db folder is that you can then "restore" your backup with a different version of Subversion. (trust me, I've lived through a catastrophic failure of a Subversion server and the dump format stays the same across versions while whatever's in the db folder doesn't necessarily)
Windows*nix
BackupAndDump.bat
@echo off
mkdir d:\backups\Subversion\%1\_backup
rmdir d:\backups\Subversion\%1 /s /q
svnadmin.exe hotcopy d:/SvnRepo/%1/ d:/backups/Subversion/%1/
svnadmin.exe dump d:/backups/Subversion/%1/ > d:/backups/Subversion/%1.svndump
rmdir d:\backups\Subversion\%1\db /s /q
backupanddump
#!/bin/sh
mkdir -p /home/backups/svn/$1/_backup
rm -rf /home/backups/svn/$1
svnadmin hotcopy /home/svn/$1/ /home/backups/svn/$1/
svnadmin dump /home/backups/svn/$1/ > /home/backups/svn/$1.svndump
rm -rf /home/backups/svn/$1/db



The second script iterates through all the repositories in a root folder and calls the first script (which, BTW, is located in the backup root folder) for each one.
Windows*nix
SubversionBackup.bat
@echo off
d:
cd \svnrepo
for /D %%d in (*) do d:\Backups\BackupAndDump %%d
svnbackup
#!/bin/sh
cd /home/svn
for d in *; do /home/backups/backupanddump $d; done


Well, that's enough for tonight. I'm sure all you Linux gurus out there are pointing and laughing at my noob-skills.

2 comments:

jane holly said...

This professional hacker is absolutely reliable and I strongly recommend him for any type of hack you require. I know this because I have hired him severally for various hacks and he has never disappointed me nor any of my friends who have hired him too, he can help you with any of the following hacks:

-Phone hacks (remotely)
-Credit repair
-Bitcoin recovery (any cryptocurrency)
-Make money from home (USA only)
-Social media hacks
-Website hacks
-Erase criminal records (USA & Canada only)
-Grade change
-funds recovery

Email: onlineghosthacker247@ gmail .com

Fireplace Repair Bellflower said...

Thanks great blog