How to sync files/data between two PCs on a home network?

For a small set of files I'd suggest Dropbox or Ubuntu One, but it seems like you want to sync your music collection between computers, and neither of these are particularly suitable for that for two reasons:

  • They both synchronise to the internet, meaning that large collections of files will take a long time to down- and upload
  • They offer a limited amount of space (with the ability to purchase more), meaning that for a large collection of files you may end up having to fork out a lot of money

Unison, which is what I use for local replication, has neither of these limitations (inherently). You can sync over your local network, meaning that it's fast (you can also sync over the internet if you wish), and can sync as much as you want — only limited by your available disc space and bandwidth. Unison has both a GUI and a terminal interface, meaning that you can use it on your desktop and server equally. There is a good guide on the Ubuntu wiki that you may wish to refer to if you choose to use Unison.


The best tool for this is the command line tool "Rsync". If you need a GUI, try Unison or LuckyBackup, which are based around the concept of Rsync. Unison and LuckyBackup are both in the repositories.

An example of rsync might be :

rsync -vxtr /home/scaine/Pictures/ /home/OtherUser/Pictures/

...which would synchronise my Pictures directory with OtherUser's Pictures directory. The options I've specified will verify any copies, preserve timestamps/permissions during copy and will traverse subdirectories where found. Do "man rsync" for more options.

As for connecting your PCs together - either put them on a switch/hub or use the crossover cable then share the directories via samba.

EDIT : Some good points to make if the aim is to "mirror" the two PCs. This command will only "add" files from source to destination. If you need to delete, then you'll need the -delete option in there too.

On investigation, it appears that Rsync does not handle mirroring particularly well. See this to realise that you will probably find older files overwriting younger files during this update! Worse, even if you get the -update option to work and prevent this behaviour, it won't "update" the older with the younger file - it will just "skip" it. Hardly ideal.

Finally, to perform two way sync, you'll need to run the same command but reverse the source/dest. Of course, this is of limited use now, since your first command (assuming you used that -delete option) will have deleted any file on the destination that didn't exist on the source. Unison handles the two-way sync quite well, from memory.

If you're seriously trying to keep multiple edits in sync, then a Dropbox solution is the best way forward. If you can take another look at either UbuntuOne or Dropbox, symlinking might be a solution - only symlink your documents folder, say, while keeping Pictures and Music off One/Dropbox and using this rsync/unison solution for the big stuff?

Tags:

Sync

10.10