Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!


Click here to return to the '10.5: Monitor Time Machine activity via GeekTool' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
10.5: Monitor Time Machine activity via GeekTool
Authored by: mosius on Wed, Sep 16 2009 at 9:32PM PDT
I found a way to get just the last time a backup was complete. I wasn't too concerned with all the activity, I just wanted to know when it was last completed.

There's some basic timezone support and the way I laid it out I think you could figure out how to customize the format of the date output fairly easily.

#! /bin/sh

# Your computer's timezone offset
OFFSET=`date "+%z" | cut -c 1-3`

# All the following is in ZULU (GMT) time
YEAR=`grep -m 1 "<date>" /private/var/db/.TimeMachine.Results.plist | cut -c 8-11`
MONTH=`grep -m 1 "<date>" /private/var/db/.TimeMachine.Results.plist | cut -c 13-14`
DAY=`grep -m 1 "<date>" /private/var/db/.TimeMachine.Results.plist | cut -c 16-17`
ZULU_HOUR=`grep -m 1 "<date>" /private/var/db/.TimeMachine.Results.plist | cut -c 19-20`
MINUTE=`grep -m 1 "<date>" /private/var/db/.TimeMachine.Results.plist | cut -c 22-23`
SECOND=`grep -m 1 "<date>" /private/var/db/.TimeMachine.Results.plist | cut -c 25-26`

# Corrects for your computer's timezone
HOUR=`expr $ZULU_HOUR + $OFFSET`

# If the TZ shift rolled you back a day you have to adjust the DAY
# If the Day rolls to 0, I didn't bother with the roll back because of the huge issues
# of which month you roll back on and what not. The proper solution would be to do proper
# date math, but I haven't figured out how to do that in shell unless you're using the
# current system time. But here, I'm using a generated time.
if [ $HOUR -lt 0 ] ; then
HOUR=`expr '24' + $HOUR`
DAY=`expr $DAY - '1'`
fi

# Just for formatting. It adds the preceding zero to the number if it's a single digit.
if [ $HOUR -lt 10 ] ; then
HOUR=`echo 0$HOUR`
fi

echo "$MONTH.$DAY $HOUR:$MINUTE"


[ Reply to This | # ]