Is there a bash command to check to see if Time Machine has finished backing up?

Solution 1:

Here's one way - I know it's nowhere near a "proper" solution, but I imagine it would work.

ps ax | grep "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper" | grep -v 'grep'

What it does is search the process list for the backupd-helper process, then filters out the grep command itself from showing up. If the command returns > 0 results, the backupd-helper process is still active. If not, the process has ended, and so you might assume it's done.

Solution 2:

tmutil status is the Lion way now that we have a nice tool for this sort of query.

On newer OS, there is an undocumented command tmutil currentphase that shows the name of the current phase.

Solution 3:

You might also start the backup with tmutil startbackup -b. -b blocks the command until the backup has finished.

Solution 4:

tmutil status|grep -c "Running = 1"

returns '1' when running, '0' when not.

Solution 5:

Absence of backup-related processes is not assurance that a Time Machine backup is complete

On the volume to which Time Machine writes its backups: alongside the …/Latest/… directory, consider:

  • the ….inProgress/… bundle.

If that bundle exists, a backup is incomplete.