Automator: back up certain folder on specific disk, whenever its connected

Hello,


I have a question regarding Automator and setting an automatic back up. I have found a tutorial how to set a "daily back up" using automator.

https://www.macworld.com/article/1157339/business/automate-backup.html


Though, for me it would be more suitable to set the repetition rule "whenever this (flash)disk/SD_card etc. gets connected" rather then on a daily basis at certain time.

Is there a way?


Thanks for help, cheers

sindelaron

MacBook Pro with Retina display, macOS Mojave (10.14.1), Automator newbie

Posted on Nov 24, 2018 9:29 AM

Reply
3 replies

Nov 24, 2018 8:09 PM in response to sindelaron

The /Volumes folder is normally invisible, so a hoop needs to be jumped through in order to be able to select it in the file dialogs. In the the Finder's Go > Go to Folder... menu item, type in /Volumes and go to the folder - this is the hoop, you can just close the Finder window unless you want it for something else.


Open Automator, choose the Folder Action template, and select Other... in the workflow popup menu to get a dialog to choose the folder to attach it to. You won't see the /Volumes folder in the dialog, since it is invisible and all, but you just jumped through that hoop, so it will be under Recent Places in the toolbar's path popup menu.


Now you can use a Run AppleScript action to run a short script that checks the name of the volume that triggered the folder action (any disk/image mounted is added to the folder). If one you are interested in is there you continue with the backup/sync, otherwise the script cancels the rest of the workflow. Something like:


on run {input, parameters}
  set backupNames to {"name1", "name2"} -- names to look for - first match wins
  tell application "System Events" to repeat with theVolume in the input
    if (get name of theVolume) is in backupNames then return theVolume
  end repeat
  error number -128 -- user cancelled
end run


Follow the script with whatever actions you were using before before.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator: back up certain folder on specific disk, whenever its connected

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.