Restoring deleted files from an SVN repository

I’ve always idly thought that one of the brilliant things about version control was that you could recover accidentally deleted files when it became necessary. Well that scenario arose today, and I realised I had absolutely no idea how to do it. Some quick Googling later and these are the commands I came up with (courtesy of the anonymous geek at M0j0 (substitute 2064 with the revision number 1 before when you deleted the files, you can get this information using svn log --verbose, and substitute the repo’ paths with the relevant path on your own repo’):

svn cp -r 2064 https://your-repository.com/svn/some-project/trunk/site/path/to/deleted/files files

I then hit an issue whereby my repo’ wouldn’t play ball, and returned path not found. More googling ensued and pgier, commenting on a post at Sachachua supplied the following code (which worked, again substitute the revision and paths as appropriate):

svn cp https://your-repository.com/svn/some-project/trunk/site/path/to/deleted/files@2064 files

…and there we are, mistakes un-mistaked as if by magic.

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.