Page 1 of 1

Backing up USB sticks automatically

PostPosted: Sat Dec 05, 2009 8:31 am
by markauk
I'm trying to use Hazel to automatically backup a USB stick whenever it is inserted, but it's not quite doing what I'd like.

Here's how I have it set up:-
• add the USB stick to the monitored folders list
• for the stick, have a rule which matches when file pathname starts with /Volumes/USBSTICK
• when the rule matches, run a shell script:-
rsync -avh --modify-window=1 "$1" "/Users/mark/Backups$1"

What this does, is iterates through each folder at the root of the USB stick, and backs each up. However, I'd rather just have it run the shell script once for the root of the USB stick (otherwise folders/files at the root which are deleted on the USB stick still remain in the backup).

Is there some way to get Hazel just to run on the root of the USB stick (e.g. if I could just have Hazel monitor /Volumes/ that should do the trick)? Or is there a different and better way to do this?

Thanks,

mark.

Re: Backing up USB sticks automatically

PostPosted: Sat Dec 05, 2009 12:27 pm
by Mr_Noodle
I guess you could monitor /Volumes and have a rule only match the folder "USBSTICK". Just make sure you put that condition in or you end up backing up any mounted filesystem.

Re: Backing up USB sticks automatically

PostPosted: Sat Dec 05, 2009 1:43 pm
by markauk
I was hoping to do that, but how do I monitor /Volumes? That directory isn't visible in the OSX file popup when I choose a folder (and either Hazel or system prefs doesn't seem to respect the 'show hidden files' pref), and I couldn't find anything that looked right in Hazel preferences...

Re: Backing up USB sticks automatically

PostPosted: Sat Dec 05, 2009 2:27 pm
by Mr_Noodle
In the file dialog, hit '/' (slash) which will bring up a "Go to the folder" field. There you can type in the path.

Re: Backing up USB sticks automatically

PostPosted: Sun Dec 06, 2009 11:03 am
by markauk
Thanks - that did the trick!

For anyone else wanting to do this, here's the configuration:-

* monitor:-
/Volumes
* single rule:-
Full Name is NAME-OF-USB-STICK
* Do the following:-
Run shell script (embedded script):
rsync -avh --del --modify-window=1 "$1" "/Users/mark/Local/Backups/USB"

To backup multiple USB sticks, just add more conditions and make sure conditions are set to "If ANY of the following conditions are met".

mark.