define( 'WPCACHEHOME', '/srv/www/' ); //Added by WP-Cache Manager svn | Ian Chilton


Posts Tagged ‘svn’

Backing up a Subversion (SVN) Repository

March 4th, 2011 No comments

Here are some crude cron jobs I use to create nightly backups of svn repositories on the server (which will then get backed up elsewhere as part of the server backup).

The nightly backup will get overwritten each night, but a weekly backup is kept permanently.

When I say crude, they work fine for a quick job, but they are limited:

  • It’s only backing up a single repository.
  • If you need something from a few nights ago, you are stuck – you’ve only got last night and then it’s back to the last weekend (not so much of an issue with version control though as that’s the point of it! – the latest backup is all that should be needed….in theory).
  • There is nothing to delete the weekly backups. So, depending on the disk size and the size of the repository, you might fill the disk up a few years down line……hopefully you have monitoring to alert you before you get that far!
  • If the server happened to be down at the time the backup was supposed to run, you wouldn’t have a backup for that day/week
  • That said, here we go:

    # At 01:05 each day, dump the repository to a file:
    5 1 * * * svnadmin dump /home/svn/my_repository 2>/dev/null | gzip > ~/svn-backups/my_repository.svn.gz

    # At 01:15 each Saturday, dump the repository out to a unique file:
    15 1 * * 6 DATE=$(date +"%Y-%m-%d"); svnadmin dump /home/svn/my_repository 2>/dev/null | gzip > ~/svn-backups/week/my_repository-$DATE.svn.gz

    Categories: development Tags:

    Moving a Subversion (SVN) Repository to a New Server

    March 4th, 2011 No comments

    Moving a Subversion (SVN) repository from one server to another (or backing and restoring up your Subversion server) and keeping all of the history and commits is actually very easy:

    1) Dump the old repository: on your old svn server, run the following command to export out (and compress with gzip) your full repository (including all history and commits):

    svnadmin dump /path/to/repository | gzip > dump_file_name.svn.gz

    2) Copy the dump file to your new svn server:

    scp dump_file_name.svn.gz user@newserver:

    3) Create a new repository: on your new svn server, run the following command to create a new repository:

    svnadmin create /path/to/repository

    4) Import the dump file into the new repository:

    zcat dump_file_name.svn | svnadmin load /path/to/repository

    5) You then need to either re-create your working copies using “svn co” or you can use the switch command with –relocate:

    svn sw --relocate \ \

    Note that I broke the above command up over multiple lines for ease of reading but you can obviously ommit the \ if you put it all on a single line.

    Another interesting thing you can do with the dump command is just dump a single commit. The following command will just dump out the commit with revision number 100:

    svnadmin dump --incremental -r 100 /path/to/repository > dump_file_name.svn

    Categories: development Tags: