Discussion:
[BackupPC-devel] Restore bug in Rsync.pm (4.0.0alpha3)
Stephen
2015-05-13 21:57:16 UTC
Permalink
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");
}

Loading...