Skip to content

Instantly share code, notes, and snippets.

@Wartz
Last active January 15, 2022 13:56
Show Gist options
  • Save Wartz/76a78b8713c4fd0f0eceddbfc1bdcfe0 to your computer and use it in GitHub Desktop.
Save Wartz/76a78b8713c4fd0f0eceddbfc1bdcfe0 to your computer and use it in GitHub Desktop.
#!/bin/sh
enabled=`/usr/bin/defaults read /Library/Preferences/com.apple.TimeMachine AutoBackup`
if [ "$enabled" == "1" ];then
lastBackupTimestamp=`date -j -f "%a %b %d %T %Z %Y" "$(/usr/libexec/PlistBuddy -c "Print Destinations:0:SnapshotDates" /Library/Preferences/com.apple.TimeMachine.plist | tail -n 2 | head -n 1 | awk '{$1=$1};1')" "+%Y-%m-%d %H:%M:%S"`
echo "$lastBackupTimestamp"
else
echo "<result>Disabled</result>"
fi
echo "$lastBackupTimestamp" > ~/Desktop/tmDate.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment