Can’t call method “getStats in BackupPC

Whenever you are doing a full backup and DumpPreShareCmd fails, I get the following error in my log:
	Can't call method "getStats" on an undefined value at /usr/share/BackupPC/bin/BackupPC_dump line 1160.

I posted a similar bug report back in December, but now I believe I
have figured out the problem. 
------------------------------------------------------------------------

IF DumpPreShareCmd or DumpPreUserCmd fails, then the routine
BackupFailCleanup is called. In the case of a *full* backup, the
routine checks to see if there is a partial backup that needs to be
saved. In particular, the following 'if' statement (line 1160) is
executed: 
		  if ( $nFilesTotal == 0 && $xfer->getStats->{fileCnt} == 0 ) {

This gives the above error since $xfer is only defined *after* the pre
commands are executed and hence remains undefined when a pre command
fails.

A potential solution would be to change line 1159 from:
    if ( $type eq "full" ) {
To
    if ( $type eq "full" && defined($xfer)) {

I am actually surprised that no one else has encountered this bug
since it should be rather common since if my analysis is correct then
it will occur *every* time one of the pre user commands fails on a full
backup.

Comments are closed.