Rsync

From HerzbubeWiki

Jump to: navigation, search

Contents

Debian packages

The following Debian packages need to be installed:

rsync


References

How to setup an rsync server:

man rsyncd.conf


Configuration

To let /etc/init.d/rsync start the daemon, the following change needs to be made to /etc/default/rsync:

RSYNC_ENABLE=true


Create the file /etc/rsyncd.conf with the following content:

[backups]
path = /var/backups
read only = true
hosts allow = 127.0.0.1 192.168.0.0/16
exclude = lost+found *
include = boot/*** etc/*** git/*** home/*** ldap/*** mysql/*** usr.local/*** var.lib/*** var.samba/*** var.www/***

[mp3]
path = /var/samba/media/mp3
read only = true
hosts allow = 127.0.0.1 192.168.0.0/16
uid = patrick

[itunes]
path = /var/samba/media/iTunes Media
read only = true
hosts allow = 127.0.0.1 192.168.0.0/16
uid = patrick

[electricsheep]
path = /var/www/herzbube.ch/electricsheep
read only = false
hosts allow = 127.0.0.1 192.168.0.0/16


Discussion:

  • Four modules named "backup", "mp3", "itunes" and "electricsheep" are created
  • "backup" module
    • The module provides read-only access to the directory /var/backups
    • Only clients in the network 192.168.0.0/16 can access the module
    • No authentification is required
    • The file or directory "lost+found" is not served
    • All other files or directories are also not served, unless they are explicitly named on the "include" line
    • On the "include" line, triple asterisks are necessary to allow the content of the folder to be served; without an asterisk, only the directory but not its content is served; one or two asterisks are, for some unfathomable reason, not good syntax and the entire directory is not served
  • "mp3" and "iTunes" modules
    • Most of the stuff above also applies to these modules
    • In addition, authentication is required for user patrick
  • "electricsheep" module
    • This module provides read+write access


Server side

There are different modes how rsync can be run on the server side. At the moment, I am only interested in the Daemon mode, because that is what is required for my purposes:

  • my client should run from a cron service on my Mac
  • my client should not need to authenticate

If authentication is necessary and my client (run from cron) should still perform an automatic login, some SSH configuration is required: possibly the .ssh/config file, but I am not sure about this.


Client side

To synchronize with an exported module

rsync -avz pelargir::backup ~/Desktop/backup

To list all available modules:

rsync pelargir::

To incrementally copy files to a writable module (files on the destination side are never deleted, even if they disappear on the source side):

rsync -tqz ~/Library/Application\ Support/ElectricSheep/*.mpg pelargir::electricsheep

Access from cron

0 21 * * *  rsync -aqz pelargir::backup ~/Desktop/backup
Personal tools
francesca