Subversion file removal

I performed one of my no-no’s today by accidentally adding my wp-config.php file to a svn repo full of database password goodness. That’s not good. Anyways, it’s a simple enough procedure to revert the issue and continue on with your complete repository as it was just without that file and it’s contents.

cd /var/svn
svnadmin dump repository-name > ~/repository-name.dump
svndumpfilter exclude trunk/wp-config.php < ~/repository-name.dump > ~/repository-name.dump-new
mv repository-name repository-name.bak
svnadmin create repository-name
svnadmin load repository-name < ~/repository-name.dump-new

A quick line by line explanation:

I start off by dumping the repository into a dump file (great, we now have a backup, but you were already keeping backups anyways). Then with the svndumpfilter
we exclude the nasty file that you don't want and put that into a new dump file. Remeber that it's relative to the root of the repository so if you put stuff into trunk you need to prepend your file with trunk, also it does not search out that file name recursively, it's directly getting that specific file. Now that I have my new clean dump file I will backup my repository directory just in case I make a mistake and then create a new repository and finally I load that new repository from the new dump file. That's it!

A final note, I did have to checkout my local working copy again after this as it was still under the impression that the wp-config.php file was still versioned. Probably because it wrote that to the local .svn folders and it doesn't check that again in the repo, I'm sure there would be several ways to correct that but this was simple enough to do.

Leave a Reply

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