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).
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 :
...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?
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:
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.
A couple of gui based alternatives if you don't want to or like using the terminal
grsync as the name implies a basic gui to
rsync
.unison unison uses more alternate backends than
grsync
but other than that they do the same thingYou can install them from the Software Center or using
apt-get
Simple answer:
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.