So... we lost our SVN repository. Through unfortunate circumstances, we also have no viable backup.

What to do? Just do an "svn export" from someone with the most recent update and start over? Is there any way to recover any history? Or connect our local checkouts to a new server?

  • 1
    The very first thing to do is take a lesson from it and sort out your backups. – John Gardeniers Sep 9 '10 at 0:13

If all you have is a checkout, you've got a snapshot of the code, but no history.

You can create a new repo from that. As to having existing checkouts connect to the new repo after you've set it up, it's probably more trouble than it's worth. It'll be easier to create a new repo from the oldest checkout and then commit changes from newer checkouts as updates.

As to recovering history, I don't see how that's possible without a dump of the repo (via svnadmin dump) at some point in time. Even an old dump would give you whatever history there was from the creation of the repo up to where the dump was made.

Maybe somebody used git-svn on your repo at some point? That might have preserved some history but getting that back into a new Subversion repo might not be easy.

Data recovery is expensive, but it might also be an option if the storage device your repo was on hasn't been physically destroyed or destructively overwritten (and it wasn't an SSD).

  • Thanks Mark, you covered all the bases. I will just recreate the repository from our latest working copy. – user21146 Sep 8 '10 at 21:07

If you've truly lost your repo, with no backups, then yes - its gone. There's no magic that can restore truly lost data.

So, if you have a working copy from someone, you can create a new repo and add the files to it. You lose all history (obviously) but history has already been lost.

You could send the hard drive off to a recovery company to try and get any data restored. Once you have the repo (or at least the db/revs and db/revprops directories), you can re-create the repo from them (by copying them to a new repo's directory). If it turns out you don't have the entire db then things will be a bit more tricky, but its still possible to restore the rest of the data - you may have to send it all off to collabnet and get some support from them to restore the mangled data files into a new, working repo.

Now, you say "svn export" from someone with the most recent update.... that suggests the person has a backup copy that you can export from. Is this the case, or were you confusing it with a working copy?

  • Export doesn't require the server... I just meant that we should get the export from whoever had done the latest update on their tree, so we get as close as possible to what was on the server. Thanks for the advice. – user21146 Sep 8 '10 at 21:03

As Mark is saying above, if you don't have a dump of the repo (from the server), you can't construct the history. An SVN checkout only contains the tip of where it is checked out. Sorry, you are SOL. I guess this is why people like distributed source control. In our company I set it up to send svn diffs to amazon s3 twice a day.

  • +1 for S3 as a inexpensive off-site backup store for SVN – jnoss Sep 9 '10 at 0:49

In addition to the useful information in the other answers, you might consider this as an opportunity to look into distributed source control (DVCS, e.g. git and mercurial, I think there are others as well). With a DVCS each user has a copy of the repository, providing more redundancy, reducing the risk of losing the full repository.

There is a very nice online book about git here: http://progit.org/

  • 2
    +1 for taking the opportunity to migrate to git (or another distributed version control system, like Mercurial). You may have just lost all your history, but taking advantage of the disaster can net you some long-term wins... – voretaq7 Sep 8 '10 at 20:42
  • +1 @voretaq7: thanks for your thoughtful expansion my my answer, it motivated me to edit - taking your comment as an example of a much more useful contribution. Thank you. – qxotk Sep 9 '10 at 1:25

First: having no backup of a SVN-Repo is a pain and should never happen. But, the same happened to me. I started to add thousands of files again, file for file, because I don't want to checkin temporary or other no-source-files.

Nearly all history is lost. But not the last checkin state is lost! I managed to get the last checkin state, so the new repo was similar to the old one and I got also the last diff!

This is my recipe:

  1. backup your local checkout
  2. clean up your local checkout see: screenshot svn-cleanup_to_last_state
  3. create new repo
  4. checkout new repo into new empty folder
  5. copy the old cleaned copy into new folder
  6. add simply all files
  7. commit it
  8. overwrite your new checkout folder with the backup from 1.

now you've got all files as before, with the last diff and only the files versioned, like before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.