Skip to content

Instantly share code, notes, and snippets.

@Nyr
Created Mar 4, 2015
Embed
What would you like to do?
Workaround for Time Machine skipping automated backups
#!/bin/bash
# .tmfix.sh - workaround for Time Machine skipping automated backups
#
# Put this script in: ~/.tmfix.sh
# Fill this with your Time Machine dir:
TMDRIVE="/Volumes/Time Machine/"
# And add something like this to your crontab:
# * * * * * /Users/Nyr/.tmfix.sh > /dev/null 2>&1
# if it's the first time...
if [[ ! -e ~/.lastbackup ]]; then
touch ~/.lastbackup
exit
fi
oldenough=$(find ~/.lastbackup -mmin +60)
if [[ ! -z $oldenough ]]; then
# exit if a backup is currently running
if [[ -e ~/.doingbackup ]]; then
exit
fi
# exit if time machine drive isn't mounted
if [[ ! -e $TMDRIVE ]]; then
exit
fi
touch ~/.doingbackup
tmutil startbackup -b
touch ~/.lastbackup
rm ~/.doingbackup
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment