Results 1 to 6 of 6

Thread: rsynch server tutorial

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question rsynch server tutorial

    Hi all,
    I am using Ubuntu 10.4.3 LTS, and I want to set up an rsynch server on my desktop that will periodically synch my laptops to itself, and the other laptops. I've never done it before, and I'm looking for a simple tutorial that can get me up and running fast.
    ~Conradin~

  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,707
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: rsynch server tutorial

    Although you can set up the rsync daemon to implement that, I think using rsync over ssh would work just fine (I think it's easier to configure, too).

    For unattended scripts I would recommend setting up ssh 'Public Keys' (so you can connect with no passwords).

    For the backup schedule you can use crontab.

    Does that help?
    Regards.

  3. #3
    Join Date
    Oct 2007
    Location
    Minnesota
    Beans
    510
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: rsynch server tutorial

    You can make a script like this:

    Code:
    #!/bin/bash
    rsync -avt --delete /target /destination
    Save it as "backup.sh" or whatever you want.

    Make the script executable (chmod +x /path/to/file/backup.sh) and either manually run it (./backup.sh or right-click>execute) or you can set it up to run automatically via crontab. Let me know if you need help setting up a crontab job.

    Code:
    man crontab
    Check out my Youtube channel for some awesome gaming videos, including Dragonforce, "Through the Fire and Flames" on Expert Performance Mode from Guitar Hero III. My Youtube Channel

  4. #4
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: rsynch server tutorial

    Thanks for the post backs.
    I think I am confused. Is rsync just a way to push data on to a shared folder like a samba share?
    ~Conradin~

  5. #5
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,707
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: rsynch server tutorial

    It is much more than that.

    It can sync directories remotely over a LAN or even the Internet. There are two protocols you can use:
    • Setting an special service (rsync daemon), or
    • Using rsync over ssh (which is encrypted).

    I personally use rsync over ssh to share family pics and videos with my brother who is out of the country.

    I found this is a basic tutorial on how to do remote backups using rsync over ssh.

    I hope it is a bit more clear now.
    Regards.

  6. #6
    Join Date
    Jan 2008
    Beans
    105

    Re: rsynch server tutorial

    This is the script I crafted, and tweaked to do my backups (as incremental dated backups, using hardlinking between them to save on prevented duplication, each dated backup capable of being copied out and then used without any special effort).


    Code:
    #!/bin/bash
    
    # expects that password-less SSH key based authentication has already
    # been configured on the client and server sides of the operation
    # otherwise expect to enter user's SSH password/passphrase several times
    # for commands passed to the server
    # Date examples imply that "today's" backup is being done 2011-10-29
    
    # config
    ## host name of ssh/rsync server
    SYNCSERVER=torrents
    ## what to sync
    SYNCWHAT=/home/`whoami`  #'my' home directory
    ## where to sync it, as the server filestructure would recognize it
    BASEDIR=/mnt/torrent-pool/home-backups/`whoami`@`hostname`
    ## can be changed to taste if backups need to happen more often than daily, or whatever
    NOW=`date +%F`
    # end of config
    
    WORKDIR=$BASEDIR/$NOW
    NOWDIR=$BASEDIR/now
    YESTERDIR=$BASEDIR/last
    # assumes that $BASEDIR/last was left pointing to $BASEDIR/2011-10-28
    
    #setup
    ssh $SYNCSERVER mkdir -p $WORKDIR
    # ex. $BASEDIR/2011-10-29
    # may work without pre-creation, but why tempt fate?
    ssh $SYNCSERVER rm -fv $NOWDIR
    # ex. $BASEDIR/now
    ssh $SYNCSERVER ln -s $WORKDIR $NOWDIR
    # ex. $BASEDIR/2011-10-29 -> $BASEDIR/now
    
    # act
    rsync -aHP $SYNCWHAT $SYNCSERVER:$NOWDIR --link-dest=$YESTERDIR
    
    # cleanup
    ssh $SYNCSERVER rm -fv $YESTERDIR
    # ex. $BASEDIR/last
    ssh $SYNCSERVER ln -s $WORKDIR $YESTERDIR
    # ex. $BASEDIR/2011-10-29 -> $BASEDIR/last
    # so that tomorrow (2011-10-30), 'today sync' will be 'yesterday sync'

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
  •