Arcee
Monday, March 29th, 2010
Picture of Arcee from Transformers, copied from this image

Picture of Arcee from Transformers, copied from this image
using mysqldump is a quick an easy way to backup databases, but restoring a single table (possibly to retrieve a single row) is a pain in the arse.
This article has a useful perl script which does just that
The bit that does the actual work is quite simple:
<snip>
125 ## go through the file one line at a time
126 while (my $line = <STDIN>) {
<snip>
140 ## set a flag when we encounter the table we want
141 if ($line =~ /^-- Table structure for table `$conf{'tableName'}`/) {
142 $flag = 1;
143 printmsg("Turning flag on", 1);
144 }
145 ## turn flag off as soon as we encounter next table definition
146 elsif ($line =~ /^-- Table structure for table/) {
147 $flag = 0;
148 printmsg("Turning flag off", 1);
149 }
150
151 ## if flag is set, then print to STDOUT, otherwise just move on
152 if ($flag) {
153 print $line;
154 }
<snip>
156 }
I keep my “documents” and “photos” folders synced to an external hard disk
rsync --modify-window=2 -avz Documents/ /media/LACIE/Documents/
The –modify-window is because the fat32 filesystem on my USB disk has lower precision when it comes to time so rsync thinks all the files have been modified. This flag sets a window of 2 seconds.