Skip to content

Instantly share code, notes, and snippets.

@haron
Last active September 30, 2023 20:11
Show Gist options
  • Save haron/58a156d83527bbe1e450aedc7b5c0642 to your computer and use it in GitHub Desktop.
Save haron/58a156d83527bbe1e450aedc7b5c0642 to your computer and use it in GitHub Desktop.
Command line tool to show Time Machine backup progress in a human-readable form (Python 3.8+)
#!/usr/bin/env python
import plistlib
import subprocess
res = subprocess.run("tmutil status -X", shell=True, capture_output=True).stdout
data = plistlib.loads(res)
if running := data["Running"]:
print("Backup is running")
print("Progress: %s%%" % (round(data.get("Progress", {}).get("Percent", -1) * 100, 2)))
print("BackupPhase:", data["BackupPhase"])
print("Stopping:", data["Stopping"])
else:
print("Backup is not running")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment