4

I have (at the moment) three mobile USB mass storage devices (flash drive, phone, e-reader). I'd like to always have the latest versions of all my files with me (such as CV, passport, research papers, source code, etc.)

My files change often, so manually copying them every day is not feasible. Ideally, I'd like to plug in my flash drive (for example), have my PC automatically recognize it, mount it, sync it and unmount it.

And the following features 'would be nice':

  • GUI
  • Notification through Xorg/KDE/Gnome when syncing starts / stops.
  • And, why not: two way syncing. But that's not a priority.

I've found some questions that are related to this one:

But none of them answer my question completely. I suppose I could hack something together myself using udev, rsync, etc., given enough time. But I'd hate to reinvent the wheel. And time is something I don't have to spare right now. Ideally I'd like to use an existing solution, but I can't find one.

So, what would be the quickest way to set something like this up?

3

You can go the udev/rsync route but you will need to do some scripting. Check out inotify-tools in any case, these are very useful for sending filesystem change notifications to applications.

I know of three GUI (quick to set up) tools for synchronizing local filesystems.

  1. Unison is mature and well-documented. Monitoring methods are slightly outdated but it could be automated by inotify (still requires some scripting).

  2. DirSync Pro doesn't sound like free software, but it is.

  3. FreeFileSync is recently released but looks promising. It has an option to save directory comparisons as a batch and trigger synchronization on events, such as mounting an external drive.

  • I've quickly checked out your links, and they look promising! It's a very busy week for me, but I'll have a closer look and get back to you asap. – mhelvens Mar 4 '13 at 12:24
  • I've just installed dirsync and found that it is a good solution sourceforge.net/projects/directorysync/?source=dlp – Yurij73 May 4 '13 at 8:01
2

In addition to good @dartonw 's answer if you like to use bash script to do simlpe two-way syncro you can use rsync this way

#!/bin/sh
exitcode=1 
#do check if usb flash is mounted
if test -e '/your_path_to_usb_mountpoint';then 
exitcode=0
#from folder to usb if the files are newers
rsync -avun --inplace  /your_folder_wich_you_want_to_syncronize/ /your_path_to_usb_mountpoint ;
#from usb to folder if the files are newers
rsync -avun --inplace /your_path_to_usb_mountpoint/ /your_folder_wich_you_want_to_syncronize/ 
fi 
#if the flash is not mounted exit with exitcode=1 
exit $exitcode
  • The -n option to rsync makes this a dry-run. Remove the -n (-avu) once you feel you've got the paths right and are ready to deploy. – Daniel May 16 '15 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.