Thursday, May 15, 2014

Rsnapshot Backups Server


# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# yum install rsnapshot
# mkdir /etc/rsnapshot
# mkdir /srv/backups/snapshots
# mkdir /var/log/rsnapshot

Setting up SSH passwordless login

# ssh-keygen -t dsa
# cat ~/.ssh/id_dsa.pub | ssh root@remote_host "cat >> ~/.ssh/authorized_keys2"
# chmod 700 .ssh; chmod 400 .ssh/authorized_keys2

Configuring rsnapshot hosts

# vim /etc/rsnapshot/rsnapshot.conf
config_version 1.2
snapshot_root /srv/backups/snapshots/laptop/
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
interval daily 7
interval weekly 4
interval monthly 3
verbose 2
loglevel 4
logfile /var/log/rsnapshot/laptop.log
exclude_file /etc/rsnapshot/laptop.exclude
rsync_long_args --delete --numeric-ids --delete-excluded
lockfile /var/run/rsnapshot.pid
backup root@laptop:/ laptop/
backup_script /etc/rsnapshot/laptop.dump_databases.sh laptop_databases/

# rsnapshot configtest

Host .exclude file

# vim /etc/rsnapshot/laptop.exclude
+ /boot
+ /etc
+ /home
+ /opt
+ /root
+ /usr
+ /usr/java
+ /usr/local
- /usr/*
- /var/cache
+ /var
+ /srv
- /*

crontab

15 02 * * * /usr/bin/rsnapshot -c /etc/rsnapshot/rsnapshot.conf daily
15 03 * * Sun /usr/bin/rsnapshot -c /etc/rsnapshot/rsnapshot.conf weekly
30 03 1 * * /usr/bin/rsnapshot -c /etc/rsnapshot/rsnapshot.conf monthly
0 */4          * * *           root    /usr/bin/rsnapshot hourly 30 3   * * *           root    /usr/bin/rsnapshot daily 0  3   * * 1           root    /usr/bin/rsnapshot weekly 30 2   1 * *           root    /usr/bin/rsnapshot monthly


  • config_version 1.2 = Configuration file version
  • snapshot_root = Destination on where to store snapshots
  • cmd_cp = Path to copy command
  • cmd_rm = Path to remove command
  • cmd_rsync = Path to rsync
  • cmd_ssh = Path to SSH
  • cmd_logger = Path to shell command interface to syslog
  • cmd_du = Path to disk usage command
  • interval hourly = How many hourly backups to keep.
  • interval daily = How many daily backups to keep.
  • interval weekly = How many weekly backups to keep.
  • interval monthly = How many monthly backups to keep.
  • verbose = Self-explanatory
  • loglevel = Self-explanatory
  • logfile = Path to logfile
  • ssh_args = Optional SSH arguments, such as a different port (-p )
  • exclude_file = Path to the exclude file (will be explained in more detail)
  • rsync_long_args = Long arguments to pass to rsync
  • lockfile = Self-explanatory
  • backup = Full path to what to be backed up followed by relative path of placement.
  • backup_script = Full path to an executable script followed by relative path of placement.

0 comments: