backups with rsnapshot

a centralized backup server can easily be set up with rsnapshot. This program can pull specified remote folders with rsync.

  1. install rsnapshot
  2. edit the config file /etc/rsnapshot.conf . The default config is well documented and one has only to modify the given lines. The man page is also of great help (link). I found the following to fit my needs (the path need should be adjusted to each one’s needs)
    config_version 1.2
    snapshot_root /mnt/USBBkupDisk/rsnapshot
    cmd_cp /bin/cp
    cmd_rm /bin/rm
    cmd_rsync /usr/bin/rsync
    cmd_ssh /usr/bin/ssh
    cmd_logger /usr/bin/logger
    cmd_du /usr/bin/du
    retain hourly 4
    retain daily 7
    retain weekly 4
    verbose 5
    loglevel 3
    lockfile /tmp/
    include_file /home/bkuper/DarkTower.include
    exclude_file /home/bkuper/DarkTower.exclude
    backup DarkTower:/home/paul/ paulTower/
    backup DarkTower:/data/paul/ paulTower/
  3. the in-/exclude files are the usual one from rsync , e.g. something like this:
    /home/paul/VirtualBox VMs

    one needs to note here, that the order of include/exclude files is important! the first pattern which matches a file takes effect.

  4. the user (here bkuper) needs to be able to sign into the client machine such that it can pull the backup. (ssh-copy-id…)
  5. the interval which were defined above (retain hourly 4 retain daily 7 retain weekly 4) will be applied with a cronjob:
    $ crontab -l
    # do hourly backups at 9,13,19,23h
    0 9,13,19,23 * * *         /usr/local/bin/rsnapshot hourly
    # do daily backups at 22:50
    50 22 * * *         /usr/local/bin/rsnapshot daily
    # do weekly backups at mondays 22:40
    40 22 * * 1         /usr/local/bin/rsnapshot weekly

rsync backup only over night

it is kinda nice to have a rsync job running while the bandwidth is not needed otherwise.

  1. start a main script each night (using cron)
  2. the main script uses timeout to overlook the actual rsync script

# duration when the command should be killed

# which kill signal should be given
# 1: gracefully
# 9: hard?

timeout -s $KILLCMD \
    ${TIME}${TIMEUNIT} \

rsync script as in this post rsync backup script

rsync backup script

everyone needs a rsync backup script at some point in their life 😉   this is the one i wrote in the last couple minutes/hours/days/years …

it syncs a local folder with a folder remotely hosted over ssh.

note: its important that variables dont have whitespaces around equality sign. furthermore, no whitespaces after linebreaks (\)




# rsync options
# a: archive mode
# partial: dont delete partially copied files
# append-verify: append to partial files and then verify by checksums

rsync -a \
--partial \
--append-verify \
-e "ssh" \