rsnapshot logging

Objectives:

  1. Produce a daily backup summary email (see my post on rsnapreport for details)
  2. Keep a detailed log file with specific rsync commands showing every file backed up, detailed errors -- well, everything
  3. Keep logs for a year, but compress to save space (also keep in own dir not to clutter /var/log/)

With the config below, rsnapshot logs commands to be executed to /var/log/rsnapshot/log, it's also told to output specific rsync messages (verbose 5). Crontab entry appends the rsync messages from rsnapshot to the same logfile, so while they're logged without time stamps, each rsync entry is prepended with the time stampted corresponding rsnapshot command, so rsync messages are easy to place.

/etc/rsnapshot.conf:

verbose		5
loglevel	5
logfile	/var/log/rsnapshot/log

/etc/crontab:

# rsnapshot backups
00 2	* * *   root    rsnapshot sync 2>&1|tee -a /var/log/rsnapshot/log|rsnapreport|mail -s"rsnapreport" root
00 3    * * *   root    rsnapshot daily
45 2    * * 7   root    rsnapshot weekly
30 2    1 * *   root    rsnapshot monthly

Or without sync:

# rsnapshot backups
15 2    * * *   root    rsnapshot daily 2>&1|tee -a /var/log/rsnapshot/log|rsnapreport|mail -s"rsnapreport" root 
30 1    * * 7   root    rsnapshot weekly
0  1    1 * *   root    rsnapshot monthly

/etc/logrotate.d/rsnapshot:

/var/log/rsnapshot/log {
	rotate 52
	weekly
	compress
	missingok
}

3 Comments

  • 1. Michael Gavon replies at 13th March 2013, 8:12 pm :

    Thanks for your work.

    I have set the rsnapshot.conf and logging locations to match your recommendations
    First test is an Ubuntu 10.04 server where I am running into the following.
    Here is command:
    rsnapshot daily 2>&1|tee -a /var/log/rsnapshot/log|rsnapreport.pl|mail -s test myname@domain.ca

    And some feedback.
    Use of uninitialized value $source in concatenation (.) or string at /usr/local/bin/rsnapreport.pl line 88, line 9679.
    Use of uninitialized value $source in hash element at /usr/local/bin/rsnapreport.pl line 94, line 9689.
    Use of uninitialized value $source in hash element at /usr/local/bin/rsnapreport.pl line 97, line 9690.
    Use of uninitialized value $source in hash element at /usr/local/bin/rsnapreport.pl line 100, line 9691.
    Use of uninitialized value $source in hash element at /usr/local/bin/rsnapreport.pl line 103, line 9692.
    Use of uninitialized value $source in hash element at /usr/local/bin/rsnapreport.pl line 106, line 9696.
    Use of uninitialized value $source in hash element at /usr/local/bin/rsnapreport.pl line 109, line 9697

    Wondering if you could point me in the right direction?

    Thanks in advance,

    mtg

  • 2. Alain Kelder replies at 13th March 2013, 9:10 pm :

    Hi Michael,

    I believe the “uninitialized value” warnings were solved for me by using the latest rsnapshot from upstream (v 1.3.1 at the time I looked at it last) instead of the dated Debian package. Looks like Ubuntu 10.04 also included the same problematic 1.3.0-2 version that Debian Lenny did (see http://packages.ubuntu.com/lucid/rsnapshot).

    More info on this a couple of other issues at http://giantdorks.org/alain/rsnapreport-pl-enhancements/

    Regards,
    Alain

  • 3. David replies at 18th May 2014, 3:41 pm :

    Do you know why rsync errors don’t appear in the log file? I have verbose set to 3 so I see the “No space left on device” rsync error in the console when I run rsnapshot manually, but with loglevel set also to 3, the log just reports “/usr/bin/rsync returned 12 while processing /”. If there’s a way to have the rsync stderr stream appear in the log then that would be very handy to me when things don’t complete successfully.

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).