Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Fully automated backup of Flash drives on mount Storage Devices
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...]
    •    
  • Currently 2.20 / 5
  You rated: 1 / 5 (5 votes cast)
 
[18,103 views]  

Fully automated backup of Flash drives on mount | 7 comments | Create New Account
Click here to return to the 'Fully automated backup of Flash drives on mount' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fully automated backup of Flash drives on mount
Authored by: nvdingo on Mar 08, '07 08:09:43AM
The one change i would make to the scripts would be to NOT use the built in rsync.
the built in rsync in OS X (any version so far) is definitely the UNIX version of rsync.
rsync therefore knows nothing of resource and data forks.
You would be surprised at the number of files on your computer that still use them.
i was ended up with PDFs of file length zero until i figured it out.
Download RsyncX from some place like versiontracker.com or macupdate.com, and specify the path to the version of rsync that is installed by it.
usually /usr/local/bin/rsync
here is the output of rsync with HFS+ support

$ rsync --version
rsync version 2.6.0 protocol version 27
Copyright (C) 1996-2004 by Andrew Tridgell and others
HFS+ filesystem support for OSX (C)2004 Kevin A. Boyd
<http://rsync.samba.org/>;
Capabilities: 64-bit files, socketpairs, hard links, symlinks, batchfiles,
IPv6, 32-bit system inums, 64-bit internal inums

rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.

this version of rsync supports another option '-eahfs'
that is ONE option, not 5. i am guessing it stands for Extended Attributes HFS, but whatever it stands for, it understands data/resource forked files.
Using it has made my life much much nicer.

[ Reply to This | # ]
Fully automated backup of Flash drives on mount
Authored by: neuralstatic on Mar 08, '07 08:38:57AM
i thought as of 10.4.6 or so, apple's rsync worked with resource forks?

see http://blog.plasticsfuture.org/2006/03/05/the-state-of-backup-and-cloning-tools-under-mac-os-x/

i'm not positive since i still use rsyncX myself.

[ Reply to This | # ]
Fully automated backup of Flash drives on mount
Authored by: nvdingo on Mar 08, '07 01:48:40PM

That's good to know.
But i still have Panther Servers that i have to manage, and 10.3.9 on my trusty old G3 ibook.
So, everyone reading this hint.
double check the man page for your rsync!
if it doesn't have the -E option, download RsyncX!



[ Reply to This | # ]
Use -E option
Authored by: googoo on Mar 08, '07 10:33:34AM

The Apple version of rsync supports resource forks (I am using Mac OS X 10.4.8) if you include the -E option. See the rsync man page for details. I would suggest adding the -E option to the rsync function call in the scripts given in this hint.

-Mark



[ Reply to This | # ]
Fully automated backup of Flash drives on mount
Authored by: haguremetaru on Mar 09, '07 02:55:09AM

After doing a little bit of looking around, I found this:

http://blog.plasticsfuture.org/2006/03/05/the-state-of-backup-and-cloning-tools-under-mac-os-x/


Not too promising... but I wonder what Leopard will bring.



[ Reply to This | # ]
Fully automated backup of Flash drives on mount
Authored by: jaguarcy on Mar 10, '07 01:35:53PM
I updated the backup script to include automated handling of archives, and keeps an arbitrary number (specified in the preferences of the script) of incremental archives using rsync's --link-dest parameter. This creates what functionally amounts to FULL backups, but with a fraction of the space needed for an actual tar backup. Also it can be configured to keep at most one backup per day, or with minor editing at most one backup for any period of time.

Link to script (same as before).

As a side note, this was only tested so far with version 2.6.9 of rsync, installed via MacPorts.


[ Reply to This | # ]
Fully automated backup of Flash drives on mount
Authored by: xag on Aug 23, '09 04:33:50PM
This can be of interest: automatic back up on a USB key without a click. It's a do-it-yourself. It uses rsyncx, no other third party app. http://mogrifiers.blogspot.com/2009/08/quick-usb-backup-from-mac.html

[ Reply to This | # ]