Quick Recipe – restoring a corrupted SVN master repo with the slave repo

Technical, Technology

With svnsync, you could set up a replica of your SVN repository.  Apart from load balancing, the slave repo is also a backup of your master repo.

When in times you’d like to recover the master (we call it the original master) from the slave, you could follow these steps:

  1. Ensure no one is committing to SVN.
  2. Trigger svnsync in all SVN slaves.
  3. Stop the master’s SVN service.
  4. Duplicate your slave repo.  We call the duplicate the new repo.
  5. Change the UUID of the new repo to that of the original master.
    svnlook uuid <path to master repo> # Gives the master's UUID
    svnadmin setuuid <path to new repo> <master's UUID>
    svnlook uuid <path to new repo> # Check if it is set correctly
  6. In physical file system, backup and move away the original master.  Move and rename the new repo to exactly that of the path of the original master.
  7. Remove the hook for the slave (in my case, the file <repo>/hooks/pre-revprop-change).
  8. Add back the hook for the master (in my case, the file <repo>/hooks/post-commit).
  9. Restart the SVN service.


  1. Section “svnsync Bookkeeping” of svnbook
  2. Managing Repository UUIDs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s