Category Archives: Programming

World Backup Day

It’s world backup day today. Go forth and signup for some sort of cloud backup service, buy a usb thumbdrive or even just email yourself some of those important docs. Even if you are a super-geek and have a multi-location automated system in place go ahead and make an extra backup for yourself just to be sure and while it’s running verify that all your systems are working well and then do a test recovery too to be sure that you are backing up successfully and know how to retrieve your data when you do need to go back and get something.

rsync -aPvz /home/wes remote-server:/backups

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.

Bash History Tricks

Here are a few bash history tricks that I seem to forget so I figured this was as good of a place as any to keep them written down for future reference.

Replace first instance of old with new in previous command.

^old^new

Replace all instances of old with new in the previous command.

!!:gs/old/new/