[wplug] OT - synchronizing files with memory stick

Brandon Kuczenski brandon at 301south.net
Sat Jan 7 20:37:58 EST 2006


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



More information about the wplug mailing list