Skip to content

Instantly share code, notes, and snippets.

@robinkaty
Last active August 5, 2023 18:11
Show Gist options
  • Save robinkaty/3fa8f9762fe81578bb40e9f4968d17b2 to your computer and use it in GitHub Desktop.
Save robinkaty/3fa8f9762fe81578bb40e9f4968d17b2 to your computer and use it in GitHub Desktop.
Multi Destination Time Machine Backup
#!/bin/sh
(
exec 2>&1 ;
time (
set +e
echo "Start Time: `date`"
/usr/bin/tmutil destinationinfo
echo "===================================================="
/usr/bin/tmutil destinationinfo | grep "^ID" | cut -d ":" -f2 | while read destination
do
echo $destination
echo /usr/bin/tmutil startbackup --auto --block --destination $destination
/usr/bin/tmutil startbackup --auto --block --destination $destination
echo "===================================================="
done
echo "End Time: `date`"
set -e
)
) | /usr/local/bin/mailapp.py --s -s "TimeMachine : `hostname`" rgranger@grangersr.us
#NOTE : requires command-line tools
#xcode-select --install
#check /var/mail/{username} for errors after run
#need the following grants:
# mailapp.py -h
# usage: mailapp.py [-h] [-s subject] [-c addr [addr ...]] [-b addr [addr ...]] [-r addr] [-a file [file ...]] [--input file]
# [--send]
# [to-addr ...]
# Create a new mail message using Mail.app
# positional arguments:
# to-addr message recipient(s)
# options:
# -h, --help show this help message and exit
# -s subject message subject
# -c addr [addr ...] carbon copy recipient(s)
# -b addr [addr ...] blind carbon copy recipient(s)
# -r addr from address
# -a file [file ...] attachment(s)
# --input file Input file
# --send Send the message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment