Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a desktop and a laptop with almost the same files within their home directory. Sometimes I make changes in ~/Music, ~/Documents, etc. But these changes of course don't affect the other machine.

So I want to have a solution to sync all the data in the home folders of my laptop and desktop. I can connect them with cross cable once in a while.

I don't want to use Ubuntu One or Dropbox (the files are big, and there's no need to use the Internet when both are on a home network).

share|improve this question
Dropbox also offers network sync so maybe it's not necessarily the wrong tool. – turbo Dec 1 '10 at 16:35
up vote 7 down vote accepted

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.

share|improve this answer
This is exactly what I am looking for but there is a problem in it other people have also had the same problem with unison. Do you know a solution? – Gaurav Butola Dec 1 '10 at 17:49
Hmm, I haven't seen that myself, but I found the following Debian bug that you might want to keep an eye on: — sounds like a problem with the program being interrupted. Try and remove the file it mentions and have another go. If it's persistent then you may have more luck with the commandline version (that's the one I use). Sorry I can't be of more help. – Iain Lane Dec 1 '10 at 20:59
Thanks for your help. This is exactly what I wanted, It is so really a great tool, I am syncing my data through SSH using unison. – Gaurav Butola Dec 2 '10 at 13:55

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?

share|improve this answer
I would be syncing the whole /home of both, would it be right to run? rsync -vxtr /home/user1 /home/user2 would it do two way sync? Is it going to preserve the latest edited copy of a document or just ignore the file if it exists? – Gaurav Butola Dec 1 '10 at 8:13
See my edits to the original question. – Scaine Dec 1 '10 at 10:03

A couple of gui based alternatives if you don't want to or like using the terminal

grsync Install grsync as the name implies a basic gui to setup rsync.

unison Install unison unison uses more alternate backends than grsync but other than that they do the same thing

Scaine's answer is perfectly good just adding some alternatives for users with an allergy for text commands :)

Hope this helps

share|improve this answer

Simple answer:

rsync -vzu user@ip.address:/remote/dir/*  /local/dir

The -u option compares dates and only transfers if the target date is older than the source date.

-v means verbose, -z means use compression.

share|improve this answer

Your Answer


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.