Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old May 15th, 2008   #1
50words
Gee! These Aren't Roasted!
 
50words's Avatar
 
Join Date: Feb 2007
Location: Minneapolis, MN
Beans: 191
Ubuntu 7.10 Gutsy Gibbon
Send a message via AIM to 50words Send a message via Skype™ to 50words
HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

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.

Last edited by 50words; October 10th, 2008 at 11:24 AM..
50words is offline   Reply With Quote
Old July 16th, 2008   #2
henriquemaia
Fresh Brewed Ubuntu
 
henriquemaia's Avatar
 
Join Date: Apr 2005
Location: Berlin, Germany
Beans: 1,213
Send a message via ICQ to henriquemaia Send a message via AIM to henriquemaia Send a message via Skype™ to henriquemaia
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

Thanks for this post. In my case I use Grsync to make backups over the netword and I don't have to put the -e ssh to achieve that. Also, I'm trying to make an exclusion list, but Grsync is always insisting in copying the folder I specified. I'm still trying to figure out why.

Anyway, thanks for this howto. Very useful.

Last edited by henriquemaia; July 16th, 2008 at 11:57 AM..
henriquemaia is offline   Reply With Quote
Old July 16th, 2008   #3
henriquemaia
Fresh Brewed Ubuntu
 
henriquemaia's Avatar
 
Join Date: Apr 2005
Location: Berlin, Germany
Beans: 1,213
Send a message via ICQ to henriquemaia Send a message via AIM to henriquemaia Send a message via Skype™ to henriquemaia
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

Quote:
Originally Posted by henriquemaia View Post
[...] Also, I'm trying to make an exclusion list, but Grsync is always insisting in copying the folder I specified. I'm still trying to figure out why.
hanks for this post. In my case I use Grsync to make backups over the netword and I don't have to put the -e ssh to achieve that.
Anyway, thanks for this howto. Very useful.
I figured out why and thanks to you (my fault in understanding, really). The answer is here:

Quote:
Remember that rsync will navigate relative to the directory in which it starts (the directory you identified as the source directory).
So what I was doing wrong was that I wrote the absolute path to the folders I wanted to exclude from the backup. Anyway, it doesn't make much sense to me that rsync can't understand an absolute path, but I'm happy that it works now.

Thanks for all your help (it was all already there ).
henriquemaia is offline   Reply With Quote
Old July 30th, 2008   #4
Marelo
First Cup of Ubuntu
 
Join Date: Jul 2008
Beans: 1
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

I followed your instructions, but I'm getting these erros:

luiz@aganp:~$ rsync -r -t -v --progress -e ssh /home/luiz/Música/ 10.1.133.161:/home/marelo/Músicas/
ssh: connect to host 10.1.133.161 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(454) [sender=2.6.9]

Both computers are on the same network and I've shared the "Músicas" folders at the 10.1.133.161 computer with all the permissions granted...

What could be the problem?...
Thanks!
Marelo is offline   Reply With Quote
Old July 30th, 2008   #5
50words
Gee! These Aren't Roasted!
 
50words's Avatar
 
Join Date: Feb 2007
Location: Minneapolis, MN
Beans: 191
Ubuntu 7.10 Gutsy Gibbon
Send a message via AIM to 50words Send a message via Skype™ to 50words
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

I am not all that sophisticated at troubleshooting networking issues, but it looks like you may have a network problem to solve, first.
50words is offline   Reply With Quote
Old August 1st, 2008   #6
RurouniAkira
First Cup of Ubuntu
 
RurouniAkira's Avatar
 
Join Date: Jul 2008
Beans: 3
Send a message via ICQ to RurouniAkira Send a message via MSN to RurouniAkira
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

Quote:
Originally Posted by Marelo View Post
I followed your instructions, but I'm getting these erros:

luiz@aganp:~$ rsync -r -t -v --progress -e ssh /home/luiz/Música/ 10.1.133.161:/home/marelo/Músicas/
ssh: connect to host 10.1.133.161 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(454) [sender=2.6.9]

Both computers are on the same network and I've shared the "Músicas" folders at the 10.1.133.161 computer with all the permissions granted...

What could be the problem?...
Thanks!

Seems that the 10.1.133.161 computer might not have SSH installed... try to ssh on to it without rsync !
RurouniAkira is offline   Reply With Quote
Old August 21st, 2008   #7
arrrghhh
A Carafe of Ubuntu
 
Join Date: Jun 2007
Beans: 96
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

Marelo, can you ping 10.1.133.161? if yes, then that is a good sign. now you have to ensure there's nothing blocking ssh (ie firewall or router if it's going across the 'net)
arrrghhh is offline   Reply With Quote
Old October 10th, 2008   #8
Skarpen
First Cup of Ubuntu
 
Join Date: Oct 2008
Beans: 2
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

I'm pretty new to linux, would ssh also work over the internet and not only on the intranet?
Skarpen is offline   Reply With Quote
Old October 10th, 2008   #9
50words
Gee! These Aren't Roasted!
 
50words's Avatar
 
Join Date: Feb 2007
Location: Minneapolis, MN
Beans: 191
Ubuntu 7.10 Gutsy Gibbon
Send a message via AIM to 50words Send a message via Skype™ to 50words
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

Quote:
Originally Posted by Skarpen View Post
I'm pretty new to linux, would ssh also work over the internet and not only on the intranet?
Yup. SSH is at its best over the internet. The internet is just one giant network.
50words is offline   Reply With Quote
Old October 13th, 2008   #10
Skarpen
First Cup of Ubuntu
 
Join Date: Oct 2008
Beans: 2
Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

Thank you!
Skarpen is offline   Reply With Quote

Bookmarks

Tags
how to, rsync, ssh

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:15 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry