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.

I use my laptop with Ubuntu-desktop to do all my work, but I also have a low-end desktop over at my office just sitting there. I've decided I'm going to install Ubuntu-server on it and use it to mirror my entire laptop home folder, to make things easier when I decide to format my laptop's hard-disk.

Whenever I'm at work, both machines are connected to a network and communicate easily (and high-speed) via ssh. When I'm not at work, the desktop is still accessible via ssh. Ideally, the syncing would take place automatically in the background, whenever I change something. It only needs to be one way: the changes I make on the laptop have to be synced over to the server, but the inverse is not necessary.

I know there's software for this out there, my question is: What software can I use to achieve the above objectives and also take full advantage of local-network speeds when I'm at work? Since I'll sometimes deal with large files, the syncing process needs to realise that the two computers are sharing a local network, and then take advantage of that (instead of always syncing through the internet).

Just to be clear, over-the-network syncing is actually more important to me here than over-the-internet syncing. I ideally the software would check if the former is available and, if not, try the latter; but if that's not possible, the first case is my priority.

Hope this isn't too long. Thanks in advance.

share|improve this question
add comment

5 Answers 5

up vote 10 down vote accepted

If you can only connect to your office server via SSH, then your best choice is to use rsync: it can use SSH as a transport protocol and uses a smart algorithm to speedup the transfer of large files, by sending only the changed blocks.

Since you only need one-way synchronization, just set up passwordless SSH authentication from your laptop to the office server, and then you can start with a command as simple as:

rsync -e ssh -a $HOME/ myuser@officeserv:

adding --include and --exclude options to refine the list of files/directory that you want to synchronize. For instance, transferring program settings ("dot files") can be risky if the two computers do not run the same OS (same version). My suggestion is to start by excluding all "dot files" (so, use --exclude="$HOME/.[a-z]*") and then selectively add the configuration directories of programs that can safely be shared (this has to be seen on a program by program basis). In addition, web browser cache and $HOME/.cache can always be excluded. See the "FILTER RULES" section in the rsync man page for a detailed discussion of the include/exclude rules syntax.

However, rsync does not have a "continuous-operations" mode, so you will have to run it periodically from your crontab.

share|improve this answer
    
This sounds good. I'll test it as soon as I get the server installed. One question: does the SSH protocol automatically use the shortest connection to the server? I mean: will it connect through the local network if both the client and the server are in the office network, or will it always attempt internet connections? –  Bruce Connor Oct 15 '10 at 17:00
    
By the way, you're correct about the browser cache. Any other suggestion of folders I should exclude? My objective is to sync all personal files, profiles, settings, and configuration files. –  Bruce Connor Oct 15 '10 at 17:02
1  
@Bruce Connor: SSH will connect to a remote host using the usual IP routing algorithm. Updated answer text with suggestion for an initial exclude list. –  Riccardo Murri Oct 15 '10 at 18:05
    
Thanks. To avoid conflicts I might sync my laptop's home folder to a subfolder in the server (and not the server's actual home folder). –  Bruce Connor Oct 15 '10 at 18:18
    
@riccardomurri by "passwordless SSH authentication" do you mean keyfile-based? or something else? –  d3vid Aug 22 '11 at 9:47
show 1 more comment

There is no complete, pre-packaged solution to your problem that I know of. You probably have to write some small script yourself for that.

The syncing itself could be done by rsync, as already explained by Riccardo Murri. Rsync only transfers the changed parts of files, so it is perfect for this task.

You can use the NetworkManagerDispatcher to execute scripts on connection/disconnection of a network interface. So you could write a script that checks if you are on the correct network and then calls rsync. This way your data would be automatically synced when you connect to your company network.

To periodically sync your data you can use cron, as already mentioned.

You should also consider security when using rsync via ssh. To synchronize without user intervention you'll need a passwordless keyfile. Anyone who has this keyfile can gain access to the server it belongs to. I would strongly recommend to encrypt your home folder to protect the data on the notebook and on the server.

share|improve this answer
add comment

DropBox | DropBox @ SuperUser http://www.dropbox.com/help/137

DropBox should be good in your case, works on Linux, mac, windows, easy setup and management.

Download DropBox

http://superuser.com/questions/147315/dropbox-to-sync-nix-home-folders

http://wiki.dropbox.com/TipsAndTricks/SyncOtherFolders

Have a read through - it does support syncing via symlinks and if there are certain doc, graphics, spreadsheets you have to sync - you still can maintain a copy of them in dropbox or permanently save them in dropbox location to save the hassle.

share|improve this answer
    
I don't believe you can set your Dropbox to be your Home folder (at least not yet). –  Matthew Oct 15 '10 at 16:22
    
superuser.com/questions/147315/dropbox-to-sync-nix-home-folders wiki.dropbox.com/TipsAndTricks/SyncOtherFolders Have a read through - it does support syncing via symlinks and if there are certain doc, graphics, spreadsheets you have to sync - you still can maintain a copy of them in dropbox or permanently save them in dropbox location to save the hassle. –  rihatum Oct 15 '10 at 16:27
1  
Thanks, but I'm already using dropbox accross platforms. What I'm looking for here is something that lets me sync many GBs of files without fees, and taking advantage of local networks. –  Bruce Connor Oct 15 '10 at 16:54
add comment

I would suggest using rdiff-backup over rsync. It's pretty much just rsync++.

unlike rsync which just a 1-1 mirror that transfers diffs, rsync has a history mechanism. So if you screwed up and deleted something important, you can revert back to a week ago and get it back.

On the ubuntu "server" you just need to have ssh running to apt-get install rdiff-backup.

on the client. I would either run this manually.. or via a crontab.

#!/bin/bash

  #backup.sh

  rdiff-backup -v5 --exclude path-to-annoyingfile  /home/user/ hostname::/media/data/snapshots/laptop 
  ## this will cleanup any backups older then 2weeks.  Adjust this as needed.
  rdiff-backup --remove-older-than  2W --force  hostname::/media/data/snapshots/laptop


  #!/bin/bash
  ##Restore.
  rdiff-backup -v5 --restore-as-of now --force user@hostname::/media/data/snapshots/laptop  /home/user

If you open up your port 22 to the internet.. you should be able to run the same script either ways.. just have it your hostname resolve locally to your local IP.

ie. backupSrv.penguins.org would resolve to the external IP of. 2.3.4.5 but inside your lan: to 192.168.1.253

share|improve this answer
    
I think your script is missing a few line breaks. –  Bruce Connor Oct 15 '10 at 16:49
add comment

Try Sparkleshare: http://sparkleshare.org/

There is a client in the Ubuntu repo and it has instructions on how to setup a server on their website.

share|improve this answer
    
looks like a great program - the least hacky solution; version 1.0 was released last month. –  Abe Jan 8 '13 at 17:57
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.