want to backup your linux server? looked at a few solutions. been using rsync running daily via a cron job which worked well
made a script (called sys_backup) that looks like this…
first do a ‘touch sys_backup’ on the command line without the quotes (in fact that applies throughout this page…open it with your favourite text editor and paste the following in (replacing /media/backup/local with the path to your backup directory).
#!/bin/bash
rsync –avp –delete /var /media/backup/local
rsync –avp –delete /etc /media/backup/local
rsync –avp — delete /home /media/backup/local
to run the script become root (as you’ll need that permission for /var and /etc) and run ‘./sys_backup’ without the quotes.
however, i wanted something a bit more comprehensive (and incremental) without me putting in too much effort. looked at bacula. too complicated. settled on backupninja. to install on a debian based system, as root, issue the following ‘apt-get install backupninja’ to grab it from the repos. next we want to edit the main configuration file. ‘joe /etc/backupninja.conf’ will open it and you can change the parameters to suit your setup. mine’s only a local backup so it looks a bit like this.
# |\_
# B A C K U P N I N J A /()/
# ‘\|
# main configuration file
#
# how verbose to make the logs
# 5 — Debugging messages (and below)
# 4 — Informational messages (and below)
# 3 — Warnings (and below)
# 2 — Errors (and below)
# 1 — Fatal errors (only)
loglevel = 4
# send a summary of the backup status to
# this email address:
reportemail = col@localhost
# if set to ‘yes’, a report email will be generated
# even if all modules reported success. (default = yes)
reportsuccess = yes
# if set to ‘yes’, info messages from handlers will be
# sent into the email (default = no)
reportinfo = no
# if set to ‘yes’, a report email will be generated
# even if there was no error. (default = yes)
reportwarning = yes
# if set to ‘yes’, disk space usage will be included in
# the backup email report
reportspace = yes
# where to rsync the backupninja.log to be aggregated in
# a ninjareport
reporthost =
# what user to connect to reporthost to sync the
# backupninja.log
reportuser = ninja
# where on the reporthost should the report go
# NOTE: the name of the log will be used in the report,
# use a globally unique name, preferably the hostname
reportdirectory = /var/lib/backupninja/reports
# set to the administration group that is allowed to
# read/write configuration files in /etc/backup.d
admingroup = root
#######################################################
# for most installations, the defaults below are good #
#######################################################
# where to log:
logfile = /var/log/backupninja.log
# directory where all the backup configuration files live
configdirectory = /etc/backup.d
# where backupninja helper scripts are found
scriptdirectory = /usr/share/backupninja
# where backupninja libs are found
libdirectory = /usr/lib/backupninja
# whether to use colors in the log file
usecolors = yes
# default value for ‘when’
when = everyday at 01:00
# if running vservers, set to yes
vservers = no
# programs paths
# SLAPCAT=/usr/sbin/slapcat
# LDAPSEARCH=/usr/bin/ldapsearch
# RDIFFBACKUP=/usr/bin/rdiff-backup
# CSTREAM=/usr/bin/cstream
# MYSQL=/usr/bin/mysql
# MYSQLHOTCOPY=/usr/bin/mysqlhotcopy
# MYSQLDUMP=/usr/bin/mysqldump
# PSQL=/usr/bin/psql
# PGSQLDUMP=/usr/bin/pg_dump
# PGSQLDUMPALL=/usr/bin/pg_dumpall
# GZIP=/bin/gzip
# GZIP_OPTS=’–rsyncable’
# RSYNC=/usr/bin/rsync
# VSERVERINFO=/usr/sbin/vserver-info
# VSERVER=/usr/sbin/vserver
# VROOTDIR=/var/lib/vservers
most of the settings have been left as they are. save the file with a ctrl+k+x in joe.
i’m using rdiff only but there are other options available. see the backupninja wiki for more info.
now to get an action (or backup job) sorted. from the wiki above we’re going to use the action.rdiff file. first we want to cd into the backup.d directory like so. as root ‘cd /etc/backup.d’. then ‘wget http://cloudplasma.co.uk/wp-content/uploads/action.rdiff’ to download the default configuration file. do a ‘joe action.rdiff’ to open it and tweak it to your liking. mine resembles the following…
######################################################
## source section
## (where the files to be backed up are coming from)
[source]
# an optional subdirectory below ‘directory’ (see [dest])
label = box
# only local type is currently supported
type = local
# how many days of data to keep
keep = 185
# files to include in the backup
# (supports globbing with ‘*’)
include = /var/spool/cron/crontabs
include = /var/backups
include = /etc
include = /root
include = /home
include = /usr/local/bin
include = /usr/local/sbin
include = /var/lib/dpkg/status
include = /var/lib/dpkg/status-old
# files to exclude from the backup
# (supports globbing with ‘*’)
#exclude = /home/*/.gnupg
######################################################
## destination section
## (where the files are copied to)
[dest]
# remote or local? If local, you dont need to specify a host below
type = local
# the machine which will receive the backups
host = backup
# put the backups under this directory
directory = /media/backup/ninja
# make the files owned by this user
# note: you must be able to ssh backupuser@backhost
# without specifying a password
# user = col
save it with ctrl+k+x as before. now it should run at 1.00 am every day. you can try it now by running ‘backupnija –n’ as root.
if you run into permission errors make sure that action.rdiff has 400 permissions (‘chmod 400 action.rdiff’) and that joe hasn’t left a temp version of action.rdiff in the backup directory (‘rm action.rdiff~’).














