Using Subversion to safeguard my photos

During the backup project, I created a subversion repository for all of my installation media and installation files - anything I'd need to set up a new computer. The intention was to have a system that was a solid backup for these data, available for download from just about anywhere. Over the months, I've also added other stores to the repository, such as my useful windows standalone tools.

Recently, I thought it would be useful to have all of my digital photos in the repository, both for backup purposes as well as to allow me to, say, have all of my downloaded desktop wallpapers on my machines at work and at home. What better purpose, right? The biggest pain was keeping the repository up to date without constantly needing to issue pseudo-random svn add commands every time we take pictures. (I could use scplugin to make this easier, but as I found out, it kinda sucks.)

Instead, I turned to my love for shell scripting, and fairly quickly banged this out. I used the handy svn status command with impunity to help me handle recursive adds and deletes. Of note, yes, I wish SyntaxHighlighter worked here...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

store='/Users/shelton/Pictures'
date=`date`
message="Auto-Commit on ${date}"

# Update the local store
svn update ${store}

# Recursively delete all manually deleted files
svn status ${store} | sed -e '/^!/!d' -e 's/^!//' -e 's/^ *(.*)/1/' -e 's/ *$//' -e 's/ /\ /g' | xargs svn rm

# Recursively add all manually added files
svn status ${store} | sed -e '/^?/!d' -e 's/^?//' -e 's/^ *(.*)/1/' -e 's/ *$//' -e 's/ /\ /g' | xargs svn add

# Commit! Comment includes timestamp.
svn commit -m "${message}" ${store}

exit 0

It would be really nice if there were SyntaxHighlighter support for shell scripts. Maybe that's worth working on myself, eh? Updated 2009-01-12: Sha-Zam!

This also required some modification to my rdiff-backup cronjob since, well, I didn't want to back up every single .svn directory and included files as that would effectively double the backup requirements for that directory. So, I played a bit more with rdiff-backup's options and ended up changing from this:

1
45 04 * * * rdiff-backup -v5 --print-statistics --exclude /Users/shelton/rdiff-backup.log --include /Users/shelton/Documents --include /Users/shelton/Pictures --include /Users/shelton/Music --exclude '**' /Users/shelton /Volumes/backup/BACKUP >> /Users/shelton/rdiff-backup.log

to this:

1
rdiff-backup -v5 --print-statistics --include-globbing-filelist /Users/shelton/cfg/rdiff-backup-files.txt /Users/shelton /Volumes/backup/BACKUP >> /Users/shelton/logs/rdiff-backup.log

This is obviously MUCH cleaner. rdiff-backup-files.txt looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- /Users/shelton/**/.svn
- /Users/shelton/logs
+ /Users/shelton/VM
+ /Users/shelton/Documents
+ /Users/shelton/Pictures
+ /Users/shelton/Music
+ /Users/shelton/Sites
+ /Users/shelton/bin
+ /Users/shelton/cfg
+ /Users/shelton/.tcshrc
+ /Users/shelton/.vimrc
+ /Users/shelton/.crontab
+ /Users/shelton/.ncftp
+ /Users/shelton/.screenrc
+ /Users/shelton/.htpasswd
- **

That first line, - /Users/shelton/**/.svn, is by far the most important, and took way too much trial and error to get right. Order of statements is, apparently, VERY important for rsync/rdiff-backup. Another note about the above list, I'm now backing up things that I wasn't before, namely my VM directory, which contains my Parallels virtual machines. It started to make prudent sense, though currently the only VM in there is a very tiny cfg fileset to virtual-boot my BootCamp partition. I've started doing several things differently with regard to my home backup, which I'll have to summarize at some point soon.

Feb 8th, 2008