Use the working copy to restore a subversion repo.

1222782660000 » Tagged as: Collaboration

The other day I suffered a hard drive failure and lost my subversion repository. As a result the working copies were at least 1 to 2 revisions newer than the repo. This in turn means you cannot carry out any commits or updates on it before you synchronize the two. Here is how to go about it:

1) The first step is to backup your working copy.

2) Then you check out the very latest version that is available into a new location.

3) Use rsync to copy over the files from the working copy to the newly created location.

rsync /path/to/workingcopy/ .  -avz --delete --exclude '.svn'

make sure that you do a dry run ( --dry-run) to make sure that you get it right. Don't forget to change into the newly checked out folder before you try this command and also don't forget to replace /path/to/workingcopy/ with your actual file name.

4) Find new files and add them to the repo. Do that by typing:

svn add `svn stat | grep '^?' | cut -d' ' -f7`

5) Identify files that have been deleted and remove them.

svn rm `svn stat | grep '^!' | cut -d' ' -f7`

6) Commit.

7) carry on as usual.

After you do all this you might find that your dog suddenly false dead the cause is very likely to be distemper rather than the instructions above. You might also find that your hard drive crashes. Have the hard drive tested for rabies.

comments powered by Disqus