HowTo: Usar Grsync y OpenSSH para sincronizar tu directorio /home en red

This tutorial will cover three things:

1) installing rsync, the Grsync GUI for rsync, and OpenSSH;
2) using rsync over an OpenSSH connection to syncronize your /home directory between two computers; and
3) excluding files you do not want to sync.

Reason: I use a desktop and a laptop. I want to keep my /home directory on both identical, since I use the same software, etc., on both. OpenSSH provides a secure connection if you are syncing remotely over the internet, and is a really easy way to connect to another computer on your network.

1) Installing rsync, Grsync, and OpenSSH

This is a piece of cake. Copy each of the following lines into the terminal:

Code:
sudo apt-get install grsync
sudo apt-get install openssh-server

2) Now, open up Grsync, which will be in Applications > Internet in Ubuntu, or you can hit Alt+F2 to bring up the run menu and type “grsync”.

Click the +Add button and name your new session something like “50words /home” so you can easily get to it again.

In the Source and Destination fields, enter the source–the computer you are going to sync from–in the first field. In my case:

Code:
/home/50words/

Note: you must add the trailing slash if you want to copy the contents of a directory.

In the destination field–the second field–enter the computer you are going to sync to. You have to do this using the computer’s IP address. (If you don’t know it, use the ifconfig command in a terminal. Or use System > Administration > Network Tools, and select the Network Device to see your IP Address next in the IPv4 row, if you are using Ubuntu.)

Enter it like so:

Code:
192.168.0.10:/home/50words/

Now, in order to get SSH to work, you have to click on the Advanced Options tab in Grsync and enter the following in the Additional options field:

Code:
-e ssh

I also check “Copy symlinks as symlinks”, because I want the /home directories to be identical, right down to the links in them.

3) Now, there are almost certainly some files you do not want to sync. For example, it is time-consuming to sync my Firefox cache, so I don’t do it; I have a fast internet connection, so it does not really matter to me if it is synced up.

It takes a lot of text to exclude multiple files and folders using the command line. It is easier to use a separate file to identify the files and folders to exclude.

First, in the Additional options field, enter “–exclude” and the text file name in which you will list your files or directories to exclude. For example, here is my path to my exclusion file:

Code:
--exclude-from=/home/50words/rsync-exclude.txt

In that text file, just identify the files or directories you want excluded. Wildcards work. Remember that rsync will navigate relative to the directory in which it starts (the directory you identified as the source directory). Here is an example of the contents of an exclusion file:

Code:
/home/50words/.mozilla/firefox/*/Cache
/home/50words/.beagle

So there you go. Before you sync for real, use the “Simulation” button to make sure you don’t get any errors, and take a look at the output to make sure you aren’t accidentally deleting everything.

Edit: If you want to do a two-way sync, instead of a one-way sync, give Unison a try. It works just as well over SSH, and does a fantastic job of two-way syncing.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s