Monthly Archives: January 2015

Simple differential backups using rdiff-backup

As a user I want to have differential backups of my documents and git directories from my computer at work to my remote off-site server.

Frequency of backups is one time a day at 1:00 AM.
Retention policy is to keep backups 12 months.

Install rdiff-backup on source computer and on destination server also.

apt-get install rdiff-backup

First you have to copy SSH public key from your source computer at work to remote server.

ssh-copy-id backup@faix.cz

Edit crontab as a backup user on source computer.

crontab -e

00 1 * * *       rdiff-backup /data/documents backup@faix.cz::/disk/backup/documents/ 1> /dev/null
01 1 * * *       rdiff-backup /data/git backup@faix.cz::/disk/backup/git/ 1> /dev/null
02 1 * * *       rdiff-backup --remove-older-than 12M --force backup@faix.cz::/disk/backup/documents/ 1> /dev/null
25 1 * * *       rdiff-backup --remove-older-than 12M --force backup@faix.cz::/disk/backup/git/ 1> /dev/null

On remote server create destination directories and make sure user backup is owner of it.

mkdir /disk/backup/{documents,git}
chown backup /disk/backup/{documents,git}

From source computer run firs backup manually and check results on destination computer.

rdiff-backup /data/documents backup@faix.cz::/disk/backup/documents/
rdiff-backup /data/git backup@faix.cz::/disk/backup/git/

Setup centralised Syslog server

Server

Open access in UFW firewall port 514 tcp/udp:
ufw allow from 192.168.122.0/27 port 514

mkdir /var/log/rsyslog
chown root:adm /var/log/rsyslog

The following code in 90-rsyslog.conf should be placed before the “*.info;mail.none;authpriv.none;cron.none /var/log/syslog” entry which is done using directive $IncludeConfig /etc/rsyslog.d/*.conf in /etc/rsyslog.conf.
Be sure you replace server-name below with the name of your central logging server.

/etc/rsyslog.d/90-rsyslog.conf

# provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

# provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514

# log each machine to own rsyslog directory
$template TmplAuth, "/var/log/rsyslog/%HOSTNAME%/%PROGRAMNAME%.log"
$template TmplMsg, "/var/log/rsyslog/%HOSTNAME%/%PROGRAMNAME%.log"
  authpriv.*   ?TmplAuth
  *.info,mail.none,authpriv.none,cron.none   ?TmplMsg

if ($hostname != 'server-name') then TmplAuth
if ($hostname != 'server-name') then TmplMsg

& ~

Comment out end of file to disable error message about missing xconsole and add mail.none not to log Postfix messages to /var/log/syslog.

/etc/rsyslog.conf

# daemon.*;mail.*;\
# news.err;\
# *.=debug;*.=info;\
# *.=notice;*.=warn |/dev/xconsole

*.*;auth,authpriv.none;mail.none    -/var/log/syslog

Verify rsyslog configuration:
rsyslogd -f /etc/rsyslog.conf -N9
You should receive message below otherwise check your log for error messages.

rsyslogd: End of config validation run. Bye.

Restart rsyslog daemon:
service rsyslog restart

/etc/logrotate.d/rsyslog

#insert right after first line
/var/log/syslog
#to rotate logs from remote syslog
/var/log/rsyslog/*/*.log

Client

Add following line at end of the file.
/etc/rsyslog.conf

*.*   @home-server:514

service rsyslog restart

List of clients

home-switch
home-receiver
faix-receiver