In this article I will be talking you through how to use rSnapshot and rSync to backup your server with an email alert when the backup has been completed and what has been backed up.

  1. You must first have rSync and rSnapshot installed:
yum -y install rsync rsnapshot
  1. Once installed you will then need to create the correct configuration files for your server. Here is an example of what I use (save as backup_config.conf):
config_version  1.2
snapshot_root   /data/backups/snapshots/server/
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 3
loglevel        4
logfile /var/log/rsnapshot/backups.log
exclude_file    /etc/rsnapshot/backup_config.exclude
rsync_long_args --delete        --numeric-ids   --delete-excluded       --stats
lockfile        /var/run/
backup  mp-vps01
rsync_long_args --stats --delete        --numeric-ids   --delete-excluded
retain  daily   14


It is important to use tabs between each argument otherwise you will receive errors.

  1. Now we need to create an exclude file, this will exclude any directories that you don’t want to backup. This needs to be placed in the location specified on you conf file above(save as backup_config.exclude):
+ /var
+ /var/www
- /var/*
+ /home
- /*


When adding a sub directory e.g. + /var/www you must first include + /var and then your sub directory, you can then exclude the existing directories as I have in my example. (you dont need to use tab in this file)

4. Create the directory for backups and logs to be stored:

mkdir -p /data/backups/snapshots/server/
mkdir -p /var/log/rsnapshot/
  1. Test the backup by running:
/usr/bin/rsnapshot -c /etc/rsnapshot/mp-vps01.conf

If successful move on if not troubleshoot, ask below if you get stuck.

  1. Schedule the backup with crontab:
crontab -e
0 0 * * * /usr/bin/rsnapshot -c /etc/rsnapshot/mp-vps01.conf daily

If you would like email alerts use the following:

0 0 * * * /usr/bin/rsnapshot -c /etc/rsnapshot/mp-vps01.conf daily | mail -s "My Backup Job"


If the backup fails the email will be empty, I still haven’t figured out how to resolve this to email the errors, If you know please let me know in the comments!