Chris Tankersley

Subversion Backups and Restores

Posted on 2008-07-19

One thing that a lot of developers don't even think about is backing up their source control repository. If, like me, your code is stored in Subversion then backing up and subsequently restoring the data is easy.

Backing Up

svnadmin has an option to do a dump which is a full command history of your repository. Because of this the file can end up quite large if you have a repository with a lot of changes. A quick way to back up and compress the repository is:

$ svnadmin dump /path/to/repo | gzip -9 -c > archivename.gz

This dumps the repository straight into gzip to compress it down to then write it to a file. With a little bit of shell scripting this can be turned into a very nice backup script.

Restoring

What happens when you need to restore your repository? You load the information back in! You can take the backup we made above and reload it into the repository with:

$ gzcat archive.gz | svnadmin load /path/to/repo

This will dump your backup into a fresh repository so that it looks exactly like it did when you took the backup.


Comments