Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
I think with udev you're on the right track. But I would suggest to replace rsync with unison. It's designed for a two-way sync in contrast to rsync. –  Marco Mar 3 '13 at 23:02
1  
I hacked together just what you're looking for with udev and rsync. –  Maros Hluska Jun 8 '13 at 16:58
    
Cool! Nicely written. –  mhelvens Jun 9 '13 at 11:20
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
    
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
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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