Bug#820963: Backup with XferMethod smb and Samba 4.2 impossible in Debian Jessie

Axel Beckert <[email protected]> Wed, 18 May 2016 20:30:33 +0200
Newsgroups gmane.linux.debian.devel.bugs.general,gmane.comp.sysutils.backup.backuppc.devel
Organization The Debian Project
Message-ID <[email protected]>
Control: tag -1 + patch

Hi,

Ludovic Drolez wrote:
> Yes, a full fix won't be easy because smbclient output has changed
> since samba 4.2.

There seems to be a rather small patch in RedHat's Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1294761
https://bugzilla.redhat.com/attachment.cgi?id=1111264

To be sure, carbon copying it here:

diff --git a/lib/BackupPC/CGI/Browse.pm b/lib/BackupPC/CGI/Browse.pm
index b977f9b..6dec5fe 100644
--- a/lib/BackupPC/CGI/Browse.pm
+++ b/lib/BackupPC/CGI/Browse.pm
@@ -65,7 +65,7 @@ sub action
     #
     # default to the newest backup
     #
-    if ( !defined($In{num}) && defined(@Backups) && @Backups > 0 ) {
+    if ( !defined($In{num}) && @Backups > 0 ) {
         $i = @Backups - 1;
         $num = $Backups[$i]{num};
     }
diff --git a/lib/BackupPC/Xfer/Smb.pm b/lib/BackupPC/Xfer/Smb.pm
index eaf002e..29c1ccd 100644
--- a/lib/BackupPC/Xfer/Smb.pm
+++ b/lib/BackupPC/Xfer/Smb.pm
@@ -230,7 +230,9 @@ sub readOutput
             $t->{byteCnt} += $2;
             $t->{fileCnt}++;
             $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
-        } elsif ( /^\s*tar: dumped \d+ files/ ) {
+        } elsif ( /^\s*tar: dumped \d+ files/
+                    || /Total bytes received: \d+/i
+		) {
             $t->{xferOK} = 1;
             $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
         } elsif ( /^\s*tar: restored \d+ files/ ) {
@@ -270,6 +272,7 @@ sub readOutput
         } elsif ( /^\s*directory \\/i ) {
             $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 );
         } elsif ( /smb: \\>/
+                || /^tar:\d+/
                 || /^\s*added interface/i
                 || /^\s*tarmode is now/i
                 || /^\s*Total bytes written/i

Additionally, $Conf{BackupZeroFilesIsFatal} = 1 seems to be necessary.
Untested yet, but will test it tomorrow together with the Debian
package of BackupPC.

Found via https://github.com/backuppc/backuppc/issues/14

		Regards, Axel