Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a way to sync a folder to an USB drive when the drive is plugged in? I'd like it to sync, or copy over changes, both ways. I've seen the Back In Time and Unison-GTK applications, but I'd like for it to run as soon as the drive is mounted. What I mean is, unintrusively sync the two folders without any input from myself besides setting it up.

If this isn't possible, is it possible to run the application when the thumb drive is plugged in to remind myself to sync manually?

Thanks!

share|improve this question
1  
How do you plan to handle file conflicts? –  Octavian Damiean Mar 8 '11 at 13:32
add comment

2 Answers 2

up vote 4 down vote accepted

I'd personally lean toward udev for something like this. udev is the subsystem that's responsible for handling hardware when it's plugged in, after the kernel has loaded it, that is.

Amongst a plethora of other features, it can run a script. In your case, I'm thinking it could mount the drive somewhere and perform whatever sync features you need.

I've already written how to write a simple udev script so I'll just point you there.

For the actual synchronisation, you need something else. git is a very popular version control application that you could easily twist to your will. And there are standard backup options like rsync that you can have it merge conflicts (just not as well as something like git).

share|improve this answer
add comment

You could try making a file called .autorun in the root directory of your usb drive, and make the contents the command you want to run, like /usr/bin/rsync -av /dir/you/want/to/sync /place/to/sync/to.

share|improve this answer
    
I did this myself for a while. .autorun worked in previous versions, but not with last several versions of Ubuntu. I haven't found a suitable replacement yet. –  Shawn J. Goff Mar 8 '11 at 15:07
4  
.autorun is a potential security nightmare. There are some viruses that spread via flash drives. I assume they did the bright thing and disabled it. –  Reuben Swartz Mar 8 '11 at 16:12
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.