Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an external USB drive, which I plug into a Linux NAS. I want to keep specific folders synchronised, so changes to files in FolderA on the NAS are applied to FolderA on the USB drive, and vice-versa.

Would an appropriate solution be to run an rsync command twice, i.e. once to sync NAS to USB and then again to sync USB to NAS, e.g. as follows:

# sync NAS to USB
rsync -av --stats /share/FolderA/ /share/USBDisk1/FolderA/

# sync USB to NAS
rsync -av --stats /share/USBDisk1/FolderA/ /share/FolderA/

I'd like the process to only update/add (no deletes, just to be safe), and to be as efficient as possible.

NB: I'll be running the commands as Cron job(s).

Thanks.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

Yes, rsync running in both directions would be a (and probably the best) viable solution.

share|improve this answer
    
The problem with this is that depending on which way you synchronize first, one or the other folders will take precedence when the same file has changed on both ends. If that's ok with you, then go for it. But even then unison might be faster, since it only has to run once instead of twice (Warning: hypothesis based on zero evidence!) –  Ryan Thompson Oct 31 '09 at 7:09
add comment

You may also want to look into something like Unison. It's designed to do exactly what you want and will let you know if a file has been updated on both drives, whereas the rsync method will just clobber the file on the the USB disk.

share|improve this answer
1  
I was just about to suggest this as well. Another advantage is that it would run in one pass instead of two. –  Pete TerMaat Jun 19 '09 at 14:27
    
Thanks, I will need to compile unison for my NAS, but this looks like a good solution. –  user10097 Jun 19 '09 at 19:41
add comment

How can you ever delete something on /FolderA/ ? Next run the files are back from /USBDisk1/FolderA/ So.... How do you keep control of removing old files?

share|improve this answer
    
Yeah, good question! I don't have a solution to this. I also want to be able to rename files, which is essentially the same problem. Any ideas welcome! –  user10097 Jul 29 '09 at 20:30
add comment

Your Answer

 
discard

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