Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

  1. #1
    Join Date
    Feb 2007
    Location
    Minneapolis, MN
    Beans
    191
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    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 04:24 PM.

  2. #2
    Join Date
    Apr 2005
    Location
    Sintra, Portugal
    Beans
    835

    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 04:57 PM.

  3. #3
    Join Date
    Apr 2005
    Location
    Sintra, Portugal
    Beans
    835

    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:

    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 ).

  4. #4
    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!

  5. #5
    Join Date
    Feb 2007
    Location
    Minneapolis, MN
    Beans
    191
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    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.

  6. #6
    Join Date
    Jul 2008
    Beans
    3

    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 !

  7. #7
    Join Date
    Jun 2007
    Beans
    1,941

    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)

  8. #8
    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?

  9. #9
    Join Date
    Feb 2007
    Location
    Minneapolis, MN
    Beans
    191
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    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.

  10. #10
    Join Date
    Oct 2008
    Beans
    2

    Re: HowTo: Use Grsync and OpenSSH to sync your /home directory over a network

    Thank you!

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •