SuperDuper! reports with GeekTool
April 11th, 2007 at 9:57 pm by Dr. Drang
As promised, here’s how I get excerpts of my SuperDuper! log file to display on my Desktop. The relevant lines of the log file are extracted and edited with this Perl script:
#!/usr/bin/env perl
# Where the log files are kept.
$dir = "$ENV{'HOME'}/Library/Application Support/" .
"SuperDuper!/Scheduled Copies/" .
"Smart Update Backup from HD.sdsp/Logs";
# Get the contents of the directory.
opendir DIR, $dir;
@allfiles = readdir DIR;
# Restrict to log files.
@logs = grep /\.sdlog$/, @allfiles;
# Pick out the latest log file.
@logs = reverse sort @logs;
$latest = $logs[0];
# Get the contents of the latest loge file.
open LOG, "$dir/$latest";
@lines = <LOG>;
# Pluck out the lines of interest and delete extraneous text.
push @wanted, grep /Started on/, @lines;
push @wanted, grep /PHASE:/, @lines;
push @wanted, $lines[-2];
grep {s/^\| //; s/\\//; s/ Info \|//;} @wanted;
print join "", @wanted;
I call the script dupersummary and keep it in my ~/bin folder. The directory where the log files are kept was discussed in my earlier post. If you want to use this script, be aware that the name of the penultimate subdirectory (Smart Update…) will depend on the name of your hard disk and whether you’re doing a Smart Update, so you may need to edit that line of the script.
The log files themselves have a very convenient naming scheme:
yyyy-mm-dd hh:mm:ss -zzzz.sdlog
By using a four-digit year and two-digit months and days (with leading zeros when necessary), SuperDuper’s programmers have made the alphabetical sorting of the files the same as chronological sorting. My script takes advantage of this to get the most recent log file. The line
@logs = reverse sort @logs;
sorts the file names and then reverses their order, putting the most recent log file at the top of the list (in $logs[0]).
As I mentioned in the earlier post, the log file is in RTF format. As it turns out, except for a few header lines at the top and a trailing line with a closing brace at the bottom, the log file is plain text with no formatting instructions. My script grabs the lines that:
- have the date and time of the backup;
- start each phase of the copying process; and
- end the text of the log file, typically telling me that the copying was successful. (In fact, I’ve never seen a log file for a failed backup, so I’ve made some [reasonable, but possibly incorrect] assumptions in writing this part of the script. Maybe I should unplug my backup disk once to see what a failed log file looks like.)
The last grep command in the script deletes some extraneous (for my purposes) text in the lines. The extracted and cleaned-up lines are then sent to STDOUT.
This is where GeekTool comes in. I have GeekTool run this command every few hours and put the output in the upper left corner of my Desktop. The result is something that looks like this:

So now a single glance tells me that last night’s scheduled copy went well and my data is safely backed up.





April 17th, 2007 at 11:04 am
Nice tutorial, thanks! Currently I use commandline rsync to do backups, but this tutorial is still very useful as a Perl refresher for me.
April 17th, 2007 at 9:29 pm
You’re right that the last line or two of the log file will tell you if it failed, but I’d also add:
push @wanted, grep / Error /, @lines;
An example of the last two lines of a simple failure (i.e. the external drive not being connected) is:
| 05:30:32 AM | Info | Started on Mon, Apr 16, 2007 at 5:30 AM\cf2 \ | 05:30:32 AM | Error | The automatic copy aborted because SuperDuper! could not locate the Destination volume named Laptop Backup\cf0 .}
But perhaps it’s moot; SuperDuper won’t automatically close if an error occurs, so if you find it’s still open in the morning, it had a problem.
April 18th, 2007 at 7:25 am
Great tip!
Did you save the script as a pl file or what?
I use SuperDuper! every day and this is just what I needed to verify at a glance.
April 18th, 2007 at 10:39 am
Darrell,
Thanks for the tip on error lines in the log file. As I said in the post, I’ve never had a failure, so I didn’t know what to look for. An additional line like
push @wanted, grep /\| Error \|/, @lines;
would probably do the trick.
April 18th, 2007 at 10:45 am
Nathan,
It’s not my habit to put a “.pl” on the end of my Perl scripts, mainly because it means more typing when I call them from the command line. I saved it with the name “dupersummary” in a folder called “bin” in my home folder and—warning: geek talk ahead—set its executable bit with the command
chmod +x ~/bin/dupersummary
I use the full path to the script when telling GeekTool which command to run.
April 22nd, 2007 at 11:23 am
Sounds awesome, but I’ve run into a small snag and I’m hoping maybe you or your readers can help me out. I created the script and plugged it into GeekTool, but nothing showed. So I went to look at what should be showing, only to discover that the Logs folder inside the sdsp folder for my nightly backup is empty.
Is there a SuperDuper! setting I need to check in order to get it to write log files?
Well, even if I can’t get it working, your script had some pretty sweet examples of perl code.
April 23rd, 2007 at 9:08 am
Jed,
As far as I know, SuperDuper! makes its logs automatically—there’s no user setting for it. There are 3 things I’d check:
Make sure you can read the most recent log file from within SuperDuper! itself. Click on the Show Log… button in the Scheduled Copies window. Also take note of the name of the scheduled copy; that’s the name of the .sdsp folder.
It’s possible that your backups aren’t running because your computer is asleep at the appointed time. You can schedule a wakeup a minute or two before the backup through the Energy Saver pane of System Preferences.
It’s possible that your backups aren’t running because you’re not logged in at the scheduled time. This is the only of SuperDuper! I find annoying.
Good luck!