2

I know i can get the time stamp of the latest Time Machine backup with the command tmutil latestbackup | grep -E -o "[0-9\-]+$" but this only works when my backup disk is plugged in. If not, i get the error message Unable to locate machine directory for host.

Is there any other way to figure out (through scripting) when the last backup was made?

I'm running OS X Mavericks and the use case would be to eventually run this as remote monitoring for Macs, say, using collectd.

1
  • 2
    This might be of some use: defaults read /Library/Preferences/com.apple.TimeMachine.plist Destinations | grep "BACKUP_COMPLETED_DATE" Commented Sep 28, 2015 at 10:23

2 Answers 2

2

Parse the XML you get from settings - defaults read on the command line:

defaults read /Library/Preferences/com.apple.TimeMachine.plist Destinations | tail -4 |head -1

That is a crude way to parse the xml / plist so you could use python or swift to properly read the preference plist / xml and parse out things like the last local snapshot date, last consistency check date, etc...

defaults read /Library/Preferences/com.apple.TimeMachine.plist Destinations
0

The answer from bmike is correct if you have only one backup destination.  My explanation, unfortunately, is too long for a comment.

The "Destinations" modifier causes it to leave out the exclusions list at the end of the file.  Thus the tail -4 | head -1 will show a date and time.

However, if you have more than one backup destination, the latest backup might not be on the last destination in the list.  To get the latest backup date/time for all backup disks, I would use

defaults read /Library/Preferences/com.apple.TimeMachine.plist | \             
grep ConsistencyScanDate

On my system, the times are in UTC.  I suspect that’s standard.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .