Restoring from backups with F-Spot
I recently had to restore from backups on my laptop, and fortunately all of my pictures were backed up. When I went to import them into F-Spot, I noticed (to my dismay) that the dates on at least a third of the pictures were set to the current date instead of the date they were taken. No EXIF data?! Aghast, I set off in search of a solution.
F-Spot stores your photos in a %YYYY/%MM/%DD directory structure, which makes things easy. I wrote picture-toucher.pl, a perl script that uses File::Touch and DateTime to change the modification time on every picture file.
All of those files now have “noon” as their modification time, but it’s better than nothing. Because F-Spot uses the EXIF data when it’s available, nothing changes for files that have EXIF data.
Backing up OpenWRT
I recently got a Linksys WRT54GL router, and I installed OpenWRT, an open-source Linux firmware. But I ran into a sticky problem – how do I back it up? Using scp doesn’t work because scp doesn’t have a way to ignore symlinks. Heavier tools (like rsync) would be great, but they are too heavy for a tiny embedded system like this. This might seem obvious to some, but this way worked quite well:
ssh user@domain.com "tar cv /bin /etc /lib /sbin /tmp /usr /www" > openwrt.tar
Why not gzip the output? Well, remember that the WRT54GL is a tiny embedded system – 16M of RAM and 4M of flash memory. You can’t zip the whole thing up because piping tar to gzip on my router because it would use up all of the available free RAM. By only using the bare minimum (tar) you can successfully get this to run in about 600K of free memory.
Why enumerate all of those folders? OpenWRT routers have /jffs and /rom, among other things, which are overlayed to give you the image you have of the root filesystem. Excluding those (and /dev and /proc) skips a lot of unnecessary file copying.
The resulting file size was 6.5M, and when gzipped it was 2.6M, which agrees quite well with the 2.9M that I expected based on the disk usage in the compressed JFFS filesystem.
I’m planning an extensive “Asterisk on WRT54GL” tutorial soon, so if you’re interested in what you can do with a little bit of Linux and a tiny, in-expensive wireless router, check back with me in a few weeks.
Reliable InnoDB hot backups
There are number of blog posts out there that mention --lock-all-tables as a good option to backup MySQL tables with mysqldump – even InnoDB tables. Don’t do that! That option is for MyISAM tables that don’t do transactions. InnoDB has ooey-gooey transactional goodness that will take a consistant backup without locking all your tables and keeping your applications from running in the meantime. Just do your InnoDB hot backups like this:
mysqldump -u USERNAME -p --add-drop-table --add-locks --create-options --disable-keys --extended-insert --quick --set-charset --single-transaction --all-databases | gzip > OUTPUTFILE
Then viola! No nasty table locks!


