##Start backup when USB-Drive is mounted##
Hint: This documentation is for MacOS only!
- Start Automator
- Create a new "folder action"
- Choose "other" in the Folder-Dropdown
- Hit: CMS+Shift+G on the keyboard
- Enter Folder Location: /Volumes
- In the Library on the left: "Utilities" -> Start AppleScript
- Copy this AppleScript to the code-box
property USBName : "USBDrive-Home"
set currentDisks to paragraphs of (do shell script "ls /Volumes")
if (USBName is in currentDisks) then
do shell script "/Users/jstrobel/tools/backup_usb_home.sh"
end if
- Change "USBDrive-Home" to the name of your USB-Drive
- Save
The Backup-Script:
rsync -rlptg /Users/jstrobel/Documents/projekte "/Volumes/USBDrive-Home/" --exclude-from=/Users/jstrobel/.rsync/exclude
diskutil unmountDisk force "/Volumes/USBDrive-Home"
You see a little "gear" in the taskbar, when the Script is running. After it is finished the USB-Drive will unmounted.