Restore bug in Rsync.pm (4.0.0alpha3)

Stephen <[email protected]> Wed, 13 May 2015 17:57:16 -0400
Newsgroups gmane.comp.sysutils.backup.backuppc.general,gmane.comp.sysutils.backup.backuppc.devel
Message-ID <[email protected]>
I'm running BackupPC 4.0.0alpha3 and recently had the occasion to perform a 
restore via rsync.

I attempted to restore the /etc/apache2 directory on a server to 
/tmp/apache2 on a different server for reference. The share name is '/' on 
the server. The /tmp/apache2 directory existed on the destination.

The restore reported success, however restored no files.

In the logs, I saw the following:
-----
Trimming /etc from filesList
Wrote source file list to /srv/BackupPC/pc/my.server/.rsyncFilesFrom9567: /apache2
Running: /usr/local/bin/rsync_bpc --bpc-top-dir /srv/BackupPC 
--bpc-host-name my.server --bpc-share-name / --bpc-bkup-num 32 
--bpc-bkup-comp 3 --bpc-bkup-merge 32/3/4 --bpc-log-level 1 -e /usr/bin/ssh 
-q -c arcfour -x -l backuppc --rsync-path=sudo /usr/bin/rsync --recursive 
--super --protect-args --numeric-ids --perms --owner --group -D --times 
--links --hard-links --delete --partial --log-format=log: %o %i %B %8U,%8G 
%9l %f%L --stats -v --files-from=/srv/BackupPC/pc/my.server/.rsyncFilesFrom9567 / 
my.server:/tmp/
This is the rsync child about to exec /usr/local/bin/rsync_bpc
sending incremental file list
rsync_bpc: link_stat "/apache2" failed: No such file or directory (2)
...snip...
rsync_bpc exited with benign status 23 (5888)
-----


It seems that in $installdir/lib/BackupPC/Xfer/Rsync.pm, $srcDir is set to 
"/", never changed, and passed as an argument to rsync_bpc. Yet the 
filenames in the "files-from" file are modified to strip any parent 
directories. Therefore $srcDir needs a different value if the restored 
files' paths aren't absolute relative to the root of the backup.

The included patch (inline and attached) fixes this problem for me; I've 
performed a few restores to original and different destinations and it 
appears to work as expected.

I don't hack BackupPC code all the time, so Craig may wish to do a sanity 
check; there may be a more correct fix.

# diff -u Rsync.pm.orig Rsync.pm.new
--- Rsync.pm.orig       2015-05-13 14:17:04.825460437 -0400
+++ Rsync.pm.new        2015-05-13 17:26:23.413745286 -0400
@@ -102,6 +102,7 @@
              for ( my $i = 0 ; $i < @{$t->{fileList}} ; $i++ ) {
                  $t->{fileList}[$i] = substr($t->{fileList}[$i], length($t->{pathHdrSrc}));
              }
+            $srcDir=$t->{pathHdrSrc} if ($t->{pathHdrSrc});
              $t->{XferLOG}->write(\"Trimming $t->{pathHdrSrc} from filesList\n");
          }

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y

_______________________________________________
BackupPC-users mailing list
[email protected]
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/
backuppc4-rsync.pm.patch (text/x-diff, 465 B)
--- Rsync.pm.orig	2015-05-13 14:17:04.825460437 -0400
+++ Rsync.pm.new	2015-05-13 17:26:23.413745286 -0400
@@ -102,6 +102,7 @@
             for ( my $i = 0 ; $i < @{$t->{fileList}} ; $i++ ) {
                 $t->{fileList}[$i] = substr($t->{fileList}[$i], length($t->{pathHdrSrc}));
             }
+            $srcDir=$t->{pathHdrSrc} if ($t->{pathHdrSrc});
             $t->{XferLOG}->write(\"Trimming $t->{pathHdrSrc} from filesList\n");
         }