Backing Up Subversion and Trac

One of the biggest things people want to be able to do is back up there Trac and Subversion Repositories, I have created some scripts and a batch file to perform this job and here I will take you through the options. The scripts can be downloaded from here, and the movie can be viewed here [QuickTime | You Tube]

Save the Zip file to your desktop, and extract all files to your desktop.
Open the location of your configurations files as part of these tutorials this is C:\Data\Configuration
Drag the BackupScripts folder form teh desktop in to the Configuration folder

Within the BackupScripts folder we have three files:

  • svn-hot-backup.py - Python Script to Backup Subversion
  • trac-hot-backup.py - Python Script to Backup Trac
  • BackupSVNTrac.bat - Script to Run the python files with cetain settings

The Batch file has a few variables with in it:

  • baseDrive - Drive Letter
  • dataBaseDir -The Base Data Folder
  • svnDir - The Subversion Repository Folder
  • tracDir - The Trac Repository Folder
  • backupBaseDir - The Base Folder to Store Backups
  • backupSvnDir - The Folder for the Subversion Backups to be stored
  • backupTracDir - The Folder for the Trac Backups to be stored
  • backupScriptsDir - The Folder where the Batch and Python Scripts are stored
 

The batch file also stops the Apache Service to ensure nothing is written while the update happens, this could be left out if you wanted but I have left this here.

The Batch file then goes to the location of where the Python files are located.

We then run the SVN Python script which has the options for how many files to keep, the Subversion Repository location and finally the location to store the backups.

This is exactly the same for the Trac Backups, you can then copy each of these lines to backup my repositories.

Finally the Apache service is restarted

We also need to create the backup folders in this case these are located at c:\data\backup and has a folder for SVN and Trac.
We can then run the Batch file, and then see the ZIP files in each of the folders, and these can be safely backed up by your usual backup solution.  
Next we want to set the batch file to run daily, open Control Panel and select Scheduled Tasks
Double click the Add Sceduled Task, click next and select browse, and select the batch file. Next set the time you want the batch to run daily and finally enter the username and password.
Once created right click the task and select run to ensure it runs ok.
You can then go back to the Backup folders and double check there are now two zip files in each.

For more help with your Apache, Subversion or Trac install please contact

Posted by TV on 08/25/2008 at 12:13 AM | Categories:

4 Comments

Timothy Pinet

Timothy Pinet wrote on 10/13/08 3:24 PM

I really like all of the videos and tutorials that you have here. I had a couple issues when running your scripts but eventually I got it all to work:
1) The slashes in your BackupSVNTrac.bat file were incorrect and I needed to change them.
2) I was getting errors when I configured the batch the way I wanted to. I had to go into the svn-hot-backup.py and trac-hot-backup.py to modify the #Global Settings section to reflect my installation locations. I had to change svnlook and svnadmin (in svn-hot-backup.py) and tracadmin (trac-hot-backup.py).
3) The commenting in the trac-hot-backup.py file looks like it was copied from the svn-hot-backup.py file.
Thanks for the great script!
Big Mad Kev

Big Mad Kev wrote on 10/13/08 5:49 PM

Glad I could Help Tim,

Not sure why the slashes in the batch file could be wrong, as that is the exact batch file I fan strange.

Oh and don't forget my wish list: http://www.amazon.co.uk/gp/registry/wishlist/1O27HRSFJ84RN?reveal=unpurchased&filter=all&sort=date-added&layout=standard&x=13&y=17 :D

As for the comments yes straight copies, no point reinventing the wheel.
Psycho

Psycho wrote on 11/18/08 1:47 PM

Easy to say but needed, in a few words: THANK YOU!!!

Really, I was pi**ed off from the trac guide where nothing's clearly said, trying to make my
svn/trac running for myself and user from outside my local network! Thanks a lot again!
Bruno

Bruno wrote on 07/07/09 1:33 PM

First thanks for all the great info! It was a big help.

If you have multiple repos you can do something like that to backup them all at once:

@Echo Off

cd c:
cd "C:\apps\backup"

echo Stop Apache2.2
net stop "Apache2.2"


Set SVNFld="C:/Data/SVNRepos"
Set TracFld="C:/Data/TracRepos"
Set backupSvnDir="C:/Data/Backup/SVN/"
Set backupTracDir="C:/Data/Backup/Trac/"



For /F %%a in ('Dir /B /AD-H %SVNFld%') Do Call :REN %%a

echo Start Apache2.2
net start "Apache2.2"

GoTo :EOF

:REN

echo ------ START SUBVERSION BACKUPS ------

Echo Backup %* Subversion
svn-hot-backup.py --archive-type=zip --num-backups=14 %SVNFld%/%* %backupSvnDir%


echo ------ START TRAC BACKUPS ------

Echo Backup %* Trac
trac-hot-backup.py --archive-type=zip --num-backups=14 %TracFld%/%* %backupTracDir%


GoTo :EOF

Write your comment





Leave this field empty: