Backing up USB sticks automatically

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Backing up USB sticks automatically 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.
markauk
 
Posts: 3
Joined: Sat Dec 05, 2009 8:18 am

Re: Backing up USB sticks automatically 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.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Backing up USB sticks automatically 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...
markauk
 
Posts: 3
Joined: Sat Dec 05, 2009 8:18 am

Re: Backing up USB sticks automatically 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.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Backing up USB sticks automatically 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.
markauk
 
Posts: 3
Joined: Sat Dec 05, 2009 8:18 am


Return to Support