This was already submitted as a hint (
Automated backup of flash drives), but that script wasn't quite what I needed. I have several small thumb drives which I'd like to back up, and some of them I don't need to maintain archives for; I only need a backup in case I lose the drive. Therefore I have modified the script a fair amount, and then using the hint to
trigger backups on connect without launchd, create a modified version of Apple's backup script, which now enables me to do the following:
- Add a copy of the sync script to any thumb drive I wish to keep a backup of
- Specify in the sync script whether or not to keep an archived copy of the backup, on a per-thumb-drive basis
- Automatically backup any number of thumb drives on any number of machines with minimal setup
The folder action script scans the root of the mounted drive for the specific backup app, and executes it if found. This is a really pain-free way to maintain constant backups of all my critical work (that resides on thumb drives). And I'm fairly certain that the backup will be OK as the script is using the
rsync UN*X command with instructions to mirror the drive contents, and
tar -cz to do the archive (if required).
Additionally, I was experiencing some permission problems when using the original script because the
.Trashes and
.Spotlight folders weren't readable by the backup script. I circumvented this problem by having two options:
- Default is to exclude the .Spotlight and .Trashes folders from the rsync backup
- Optionally, the script can run the backup as an administrator, which has the side effect of asking for the administrator password every time the specific thumb drive is mounted, which might be annoying or desirable, depending on the person
The modified scripts and full instructions are located
here.
[
robg adds: In case the above-linked post isn't available at some point in the future, I've
mirrored the two scripts here on macosxhints.com...]