1

I just want to get backup last time using command-line.

With this two conditions (that the GUI, the graphical interface upper-right widget we all use normally, normally between the wifi icon and the spotlight-search icon, doesn't seem to need as well):

  • No need of any backup (TM) disc plugged.
  • No need of the "Full Disk Access" (for the shell) requirement that, for instance, tmutil listbackups, tmutil latestbackup (or all those kind of proposals would need).

(Example when i use: tmutil latestbackup

% tmutil latestbackup
Failed to mount backup destination, error: Error Domain=com.apple.backupd.ErrorDomain Code=18 "Failed to mount destination." UserInfo={NSLocalizedDescription=Failed to mount destination.} 

)

I searched the web and i didn't find any definitive answer. Some promising ones, look now to be a bit outdated. This was the most promising (perhaps made sense in ancient system organizations, unfortunately not in my case):

 % defaults read /private/var/db/.TimeMachine.Results BACKUP_COMPLETED_DATE
2023-04-08 19:05:57.429 defaults[10864:260510] 
The domain/default pair of (/private/var/db/.TimeMachine.Results, BACKUP_COMPLETED_DATE) does not exist

Actually, there is no .TimeMachine.Results in that folder (ls -a), at least in my system.

¿As long as the computer without any disc plugged, can grab the value of the last backup and present it in the desktop (upper right TM widget), that value has to be easy available somewhere. Perhaps a plist file?

2
  • Oh absolutely. Too bad I can't dive into this further, I'm still on Mojave and like I said looks like TM's changed since. I removed my comments, I'd suggest you do the same - as the comments aren't intended for discussions, the open space is a bit limited... we're already at the point where the comments will move to a chatroom... Commented Apr 11, 2023 at 19:48
  • Check out this post, all the comments, and the answer just in case it helps you identify the location where the TM backup database may exist on your syste: apple.stackexchange.com/questions/370044/…. Might try googling "Time Machine Backup Database Catalog (or index)" or something to that extent. Usually backup systems will have a database with X records in the catalog to query without loading the backup media to sync x purged records otherwise. If you determine that's the case, try adjusting to keep those longer, etc. for your needs. Commented Apr 11, 2023 at 21:55

1 Answer 1

0

I ran into a similar problem, the command I used is:

/usr/libexec/PlistBuddy -c "Print Destinations:0:SnapshotDates" /Library/Preferences/com.apple.TimeMachine.plist | tail -n 2 | head -n 1 | awk '{$1=$1};1'

It's adopted from this Reddit answer: https://www.reddit.com/r/macsysadmin/comments/6jvsyx/comment/djind3p. I have full-disk access enabled for Terminal so not sure if that is required for this command, but at least it uses a local .plist like you asked for.

6
  • /usr/libexec/PlistBuddy -c "Print Destinations:0:SnapshotDates" /Library/Preferences/com.apple.TimeMachine.plist | tail -n 2 | head -n 1 | awk '{$1=$1};1' Output: Error Reading File: /Library/Preferences/com.apple.TimeMachine.plist
    – nostromo
    Commented Jun 21 at 22:51
  • Looks like you need to give full disk access. Commented Jun 24 at 6:02
  • Not just a matter of permissions for just reading the .plist (sudo...)? I didn't try with sudo because I didn't understand the -coption. Is just a reading thing? [I don't want to mess up with .plists. Only reading is ok, but not touching them in any way] What does it does? In another vein, how do you "give full disk access"? Can you explain more on this? Thx.
    – nostromo
    Commented Jun 24 at 6:22
  • Perhaps it is indeed a matter of permissions of the file or the parent folders. The reason why I said full disk access is because I did give full disk access to Terminal and didn't get this error, without changing any of the permissions of the file or the parent folders. You can grant full disk access by going to System Settings -> Privacy & Security -> Full Disk Access. Please be aware of the security implications, especially with unsandboxed apps. If you find a way to do this without giving full disk access it's probably better. Commented Jun 25 at 9:27
  • Your starting point is surely promising and I am grateful of it, but I am looking for the most parsimonious way of doing this, without tinkering with any critical security configuration. At the end of the day, the goal is just to query time and date of last backup. If in the process, commented by an expert, there is going to be always a bottleneck that implies disabling general protections, ok, but I am not yet convinced is still the case. We will see if appears another proposal like yours enhanced or a different approach.
    – nostromo
    Commented Jun 25 at 9:45

You must log in to answer this question.

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