Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,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 whoever posted them. This site is not responsible for what they say.
10.5: Monitor Time Machine activity via GeekTool
Authored by: mosius on Sep 16, '09 09:32:11PM

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 | # ]
10.5: Monitor Time Machine activity via GeekTool
Authored by: gallen1119 on Dec 19, '09 08:52:10PM

mosius,

I like this idea of being able just get the TimeMachine last backup completed, but I'm not sure how to get you reply as GeekTool output. Is this (your post) a script that I paste into AppleScript Editor? How do I get this result as a GeekTool output on my desktop?



[ Reply to This | # ]
10.5: Monitor Time Machine activity via GeekTool
Authored by: PixelRogue on Jan 20, '10 03:27:31PM

Same question:

Would love to have a small Geek Tool desktop item tell me when Time Machine had its last successful backup... no need for all the other activity. Anyone else have some Terminal command to achieve this in Geek Tool?



[ Reply to This | # ]
10.5: Monitor Time Machine activity via GeekTool
Authored by: Aneisch on Jan 29, '10 08:28:35AM

Hey, awesome script, but is there any way to show 12 hour time as opposed to 24?



[ Reply to This | # ]
10.5: Monitor Time Machine activity via GeekTool
Authored by: taylorcc on Dec 04, '10 05:25:39PM

#!/bin/sh

lastbackupdate=$(grep "Backup completed" /var/log/system.log | tail -n 1 | awk '{print $1" "$2" "$3}')

if [ "$lastbackupdate" = "" ] ; then
echo "There has never been a successful backup!"
exit 0
else
date -j -f "%b %d %T" "$lastbackupdate" "+Last successful backup was %a, %b %d %Y, at %I:%m%p"
fi

Gives output like

Last successful backup was Sat, Dec 04 2010, at 06:12PM



[ Reply to This | # ]