#563 Issue closed: Confirming ReaR backup completed successfully - check return codes or syslog output

Labels: support / question

bbeaver opened issue at 2015-03-09 18:47:

Is there a simple way to confirm a "rear -v mkbackup" ran to completion without errors, when scripted to run automatically using cron? For example, if the "rear -v mkbackup" command is placed within a shell wrapper, is it sufficient to check the return value, (echo $?), immediately after the script finishes? We'll be running nightly with cron, and I would like to script such that I receive an email only if there are problems, or, a syslog event is triggered in the event of a problem. Thanks

schlomo commented at 2015-03-09 21:54:

Simply run read mkbackup. It will remain silent unless there is something to say. The return code should indicate success or failure.

bbeaver commented at 2015-03-09 23:53:

Run "read mkbackup"? Do you mean, "rear mkbackup", without the "-v" verbose option? And when "rear mkbackup" completes, check the return value, (echo $?), for success status? Assume return of zero is success and non-zero means there were problems, correct? Thanks

jsmeix commented at 2015-03-10 08:29:

@bbeaver

What exactly do you mean with
"confirm a 'rear -v mkbackup' ran to completion without errors"?

E.g. to confirm that the backup of the files is complete without errors one would have to restore it to another place and then inspect if the restored stuff is complete without errors.

E.g. to confirm that the generated rear recovery system is complete without errors one would have to boot and run it on another machine and let it do its job there which means one would have to do a real "rear recover" and after that verify that the recovered system is complete without errors.

Or do you only mean that no program/script that was run by 'rear -v mkbackup' resulted a non-zero exit code?

gdha commented at 2015-03-10 09:25:

Since rear-1.16.x rear writes a return code message via syslogd to var/log/messages, e.g.
Mar 10 10:22:20 <my_hostname> rear[20947]: DONE: rc=0

bbeaver commented at 2015-03-10 12:20:

@jsmeix: we are wanting to run rear backups each night via cron unattended, which means I need to know by either an email or syslog event if there were problems. I can either script for this by validating a return code, or look for a syslog event.

@gdha:
Perfect - that's what I was looking for. Will syslog also be written with any problems? What local.conf variables need to be setup to support the writing of syslog events?

Thanks

schlomo commented at 2015-03-10 12:46:

ATM the only thing that is logged to syslog are errors and a warning /
success result codes.

I think that it would be not difficult to add support for logging
everything to syslog instead of our own log file.

On 10 March 2015 at 13:20, bbeaver notifications@github.com wrote:

Perfect - that's what I was looking for. Will syslog also be written with
any problems? What local.conf variables need to be setup to support writing
syslog events? Thanks


Reply to this email directly or view it on GitHub
https://github.com/rear/rear/issues/563#issuecomment-78042663.

bbeaver commented at 2015-03-10 13:41:

Leaving details in the ReaR log file is fine. The objective here is to be notified if there are any issues with a regularly scheduled nightly run of "rear -v mkbackup". Sysadmins will need to receive an email, or a syslog event if there are problems, and once this is received they can look at the ReaR log file details as to what failed. Thinking something like this below:

rear mkbackup
rc=$?
if [ -n "${rc}" ]
then
send an email indicating rear failed, or logger to syslog
fi

gdha commented at 2015-03-10 14:11:

if you grep the syslog with the keyword rear you would find all issues if any or it went fine DONE: rc=0

gdha commented at 2015-03-25 19:19:

This issue is related to the discussion held in #564

gdha commented at 2015-05-13 16:46:

@bbeaver Doe you need some more info or are you good? Otherwise, close the issue.
thanks.


[Export of Github issue for rear/rear.]