- think shell -
  • HOME
  • BLOG
  • NETWORK TOOLS
    • GeoIP
    • CC Ranges
  • CONTACT
  • Blog
  • 2009
  • October
  • 21
  • Howto create rsync server
21 Oct
0

Howto create rsync server

Posted by branko | Tutorials. | Tags: network server ssh

There are tons of reasons why would one want to create a rsync server. For example you wish to backup your data to a remote server but you don't want to backup everything every time.

rsync is an open source utility that provides fast incremental file transfer. rsync is freely available under the GNU General Public License and is currently being maintained by Wayne Davison.

As you can see rsync is ideal for this. You can use it within ssh protocol, rsh and rsync itself. Creating a rsync server will allow you to create easily accessible storage server, update server for your scripts, etc.

Anyway let's get started on configuring rsync server which will serve as remote backup server.

First make sure you have tcp and udp port 873 open in your firewall. Next install rsync on your machine (if you don't have it yet), and xinetd as well.

yum install -y rsync xinetd

We will make rsync available trouh xinetd so you must enable it by editing its conf file

nano /etc/xinetd.d/rsync

edit the line saying:

disable = yes

to:

disable = no

so the entire file should look something like this:

service rsync
{
        disable = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

Next we want to create rsync client username and password:

nano /etc/rsyncd.secrets

and enter a username and password in format:

username:password

yes it's plain text.

Let's create a rsync server conf file:

nano /etc/rsyncd.conf

now here enter:

#maximum allowed connections
max connections = 10
#where to log
log file = /var/log/rsync.log
timeout = 300

To create a share using a password and being able to send files to rsync server, we shoulwd add to our /etc/rsyncd.conf:

[backup]
comment = Backup place for my office computers
path = /backup/
read only = false
list = yes
uid = backup
gid = backup
hosts allow = 192.168.0.0/24 # i want to limit the rsnyc server only to this group of hosts
secrets file = /etc/rsyncd.secrets
auth users = username #enter username specified in secrets file

Now we have a rsync server module at path /backup which will allow only hosts within 192.168.0.0/24 network and users authenticated by username specified in secrets file.

To make sure this will be somewhat secure let's change permissions on rsync config files

chown root.root /etc/rsyncd.*
chmod 600 /etc/rsyncd.*

Restart the xinetd:

service xinetd restart

and voila.

Let's go test it out from one of our client hosts:

rsync rsync.server.com::

backup         Backup place for my office computers

To actually backup something onto this host we would use:

rsync -avz ./ username@rsync.server.com::backup

the command would ask us for a password specified in secrets file. After successful login rsync will start to transfer files to remote machine. Next time we start it it will only transfer the differences since last time.

If you would like to script this, entering a password could be a problem. Luckily rsync offers a solution as password file.

nano /home/branko/.rsync.pass

enter your password here and chmod this file to 600 so it's only readable by you. start the rsync with following command:

rsync -avz --password-file=/home/branko/.rsync.passw ./ username@rsync.server.com::backup

To setup another share for download only we would create a read-only share without passwords. just append this to your /etc/rsyncd.conf file:

[update]
comment = update downloads
path = /home/branko/update
read only = true
list = yes
uid = branko
gid = branko
hosts allow = 192.168.0.0/24

Now you may see there is no auth user or secrets password. So when we issue the rsync command on our server again:

rsync rsync.server.com::

you will se another module available by the name update.

to rsync content from this module just use:

rsync -avz rsync.server.com::update ./
  • Previous entry
  • Next entry

Categories

  • Coding (5)
  • Linux (8)
  • Monitoring (2)
  • Services (1)
  • Tutorials (6)
  • Virtualization (3)

Recent Post

  • IPv4 country code IP ranges database

    23 June 2013
  • Apache monitoring tool ApTop beta released

    12 December 2012
  • Reclaiming InnoDB ibdata unused space.

    04 December 2012
  • Wsgi on cPanel improved

    27 March 2011
  • Django on cpanel with python2.6, virtualenv and mod_wsgi

    14 August 2010

Follow Me

Categories

  • Coding (5)
  • Linux (8)
  • Monitoring (2)
  • Services (1)
  • Tutorials (6)
  • Virtualization (3)

Archives

  • 2008
  • 2009
  • 2010
  • 2011
  • 2012
  • 2013

Recent Posts

  • IPv4 country code IP ranges database 23 June 2013

  • Apache monitoring tool ApTop beta released 12 December 2012

  • Reclaiming InnoDB ibdata unused space. 04 December 2012

© 2015 toic.org All Right Reserved