Skip to content

Instantly share code, notes, and snippets.

@interstateone
Last active March 5, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save interstateone/beb22b7073a7a53527ee to your computer and use it in GitHub Desktop.
Save interstateone/beb22b7073a7a53527ee to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# ~/bin/backup-photos
file="Photos Library.photoslibrary"
path="/Users/brandon/Pictures/$file"
read -r -p "Do you want to backup $file to the Photo Storage volume? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ && -d "$path" ]]; then
rsync -av --delete --info=progress2 "$path" "/Volumes/Photo Storage/"
fi
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ca.brandonevans.photobackup</string>
<key>Program</key>
<string>/Users/brandon/bin/spawn-photo-backup</string>
<key>StartOnMount</key>
<true/>
</dict>
</plist>
#!/bin/bash
#
# ~/bin/spawn-photo-backup
volume="/Volumes/Photo Storage"
if [[ -d "$volume" ]]; then
open -Wna Terminal.app ~/bin/backup-photos
diskutil unmount "$volume"
echo "Photo Library Backup Complete"
/usr/bin/osascript -e 'display notification "You can now disconnect the backup drive." with title "Photo Library Backup Complete"'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment