Archive for March, 2010

Arcee

Monday, March 29th, 2010

Arcee from transformers
Picture of Arcee from Transformers, copied from this image

restore a single table from mysqldump

Thursday, March 25th, 2010

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     }

Sausage Beak

Tuesday, March 16th, 2010

Made a hearty bake by following Simon’s “beak” recipe.
Thanks Simon, Thimon.

Wacko

Saturday, March 6th, 2010

rsync backup to external drive

Tuesday, March 2nd, 2010

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.