[wplug] OT - synchronizing files with memory stick

Patrick Wagstrom pwagstro at andrew.cmu.edu
Sun Jan 8 13:55:05 EST 2006


On Sat, 2006-01-07 at 20:37 -0500, Brandon Kuczenski wrote:
> I am writing a hotplug script to synchronize some directories on my local 
> machine with directories on a flash memory stick every time it is plugged 
> in, using rsync.  The synchronization is two-directional, meaning first it 
> updates local files to match newer files on the memory stick, and then it 
> updates the stick to match newer files on the local machine.  The idea is 
> that I can use this script on multiple computers and always have the same 
> set of documents to work with.
> 
> There are a few challenges.  For one, the memory stick uses vfat (which is 
> desirable so I can use the stick on windows computers if necessary) which 
> does not support preserving timestamps when copying data -- utime(2) 
> doesn't work.  To work around this, I tell rsync to compare files by 
> checksum rather than by modification time, since files copied to the stick 
> will always look as old as the time they're copied, rather than the time 
> they were created.
> 
> Second, and more interesting from an algorithmic perspective, it becomes 
> impossible to delete files: if I remove the files on one computer, then as 
> soon as I plug the stick into another computer the old file will be 
> regenerated.  I was wondering if anyone could think of a sensible way a 
> scheme like this 'should' work that would allow useless files to be 
> removed without manually deleting them from every computer on which 
> they're present.
> 
> My scripts are currently available on the web at 
> http://301south.net/works/bkp-stick if anyone wants to have a look.  Works 
> in progress, remember.
> 
> -Brandon

I just wanted to chime in and HIGHLY recommend unison.  It manages to
delete files, create new, change permissions, even will get rid of that
pesky plaque on your teeth.  It's really an amazing program.
Unfortunately, it may require a bit of user interaction once in a while
when it gets confused, but it's on a much lesser level than what's
required with a CVS/SVN setup.  It keeps a consistent image by creating
a few small metadata files which are compared against when you run it.
I've been using it for several years to keep a local copy of my complete
web directory for editing and testing.  Even when I make changes
directly on the server it manages to pick them up just fine.

--Patrick



More information about the wplug mailing list