I wanted to check the time a MacBook Pro laptop was last backed up using Apple's OS X Time Machine backup utility without the external USB-attached backup disk drive being connected to the system. The
tmutil
command can be run from a command line interface (CLI), aka a shell prompt
by running the Terminal application which is found in
Applications/Utilities. But whenever I issued any tmutil command, even
when I prefaced it with sudo
, I received the same message: "Unable
to locate machine directory for host."$ tmutil latestbackup Unable to locate machine directory for host. $ tmutil listbackups No machine directory found for host. $ tmutil compare -s Unable to locate machine directory for host. ------------------------------------- Added: 0B Removed: 0B Changed: 0B $ sudo tmutil latestbackup Password: Unable to locate machine directory for host. $ tmutil machinedirectory No machine directory found for host. $ sudo tmutil machinedirectory No machine directory found for host.
If I ran the Time Machine program itself, I saw the message "Your Time Macine backup disk can't be found."
But I was able to get the last backup time even with the backup drive disconnected from the system using the command below:
$ defaults read /Library/Preferences/com.apple.TimeMachine.plist Destinations | grep "BACKUP_COMPLETED_DATE" "BACKUP_COMPLETED_DATE" = "2015-12-09 13:18:20 +0000";
You can obtain additional information such as the number of
snapshots
stored on the drive and the date of the oldest complete snapshot of the
system's hard drive stored on the backup device using defaults read
/Library/Preferences/com.apple.TimeMachine.plist Destinations
.
$ defaults read /Library/Preferences/com.apple.TimeMachine.plist Destinations ( { "BACKUP_COMPLETED_DATE" = "2015-12-09 13:18:20 +0000"; BackupAlias = <00000000 01760002 0001134d 6163426f 6f6b2050 726f2042 61636b7 5 70730000 00000000 0000d1c1 ef55482b 00000000 0001134d 6163426f 6f6b2050 726f2042 6 1636b75 70730000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000 0000 00000000 00000000 00000000 0002d1c1 ef550000 00000000 0000ffff ffff0000 0900000 0 00000000 00000000 00000000 00134d61 63426f6f 6b205072 6f204261 636b7570 73000010 0 0080000 d1c22795 00000011 00080000 d1c22795 00000001 00000002 00274d61 63426f6f 6b20 5072 6f204261 636b7570 733a4d61 63426f6f 6b205072 6f204261 636b7570 7300000e 0028001 3 004d0061 00630042 006f006f 006b0020 00500072 006f0020 00420061 0063006b 00750070 0 073000f 00280013 004d0061 00630042 006f006f 006b0020 00500072 006f0020 00420061 0063 006b 00750070 00730012 00000013 001c2f56 6f6c756d 65732f4d 6163426f 6f6b2050 726f204 2 61636b75 7073ffff 0000>; BytesAvailable = 126685134848; BytesUsed = 373078753280; DateOfLatestWarning = "2016-01-29 23:42:56 +0000"; DestinationID = "41935539-CE2A-4F1E-96DC-B67FBC14BCA3"; DestinationUUIDs = ( "D4AF72EE-4B71-3F55-B7AF-6F0C8CF6A229" ); RESULT = 19; SnapshotCount = 30; kCSBackupdOldestCompleteSnapshotDate = "2015-07-08 05:04:05 +0000"; } ) $
If you just want one of those pieces of information, e.g., the oldest complete snapshot date, you can filter the result with grep and, if you don't want to see the text you are searching for with grep, pipe its output into the cut command. E.g. for the oldest complete snapshot date on the drive being used for Time Machine backups you can use the cut command to just display columns 49 to 59.
$ defaults read /Library/Preferences/com.apple.TimeMachine.plist Destinations | grep "BackupdOldestCompleteSnapshotDate" kCSBackupdOldestCompleteSnapshotDate = "2015-07-08 05:04:05 +0000"; $ defaults read /Library/Preferences/com.apple.TimeMachine.plist Destinations | grep "BackupdOldestCompleteSnapshotDate" | cut -c 49-59 2015-07-08