Discussion:
[BackupPC-devel] BackupPC_tarCreate without deecompression
Aleksandar Ivanisevic
2009-08-19 07:44:25 UTC
Permalink
Hi,

If I want to create an compressed archive from a backuppc backup I
have to use a tarCreate and then pipe the output to whatever
compression utility I desire. Since backuppc backups are already
compressed this is a bit of an overkill since each file is first
decompressed, then tarred and then compressed again.

Wouldn't it be much faster to just copy over the compressed files and
then decompress them at restore time with BackupPC_zcat?

The obvious disadvantage is that one needs a copy of backuppc to
restore, but I guess a standalone zcat utility shouldn't be too hard
to cut out.

This is the patch, it seems to create valid archives and im able to
BackupPC_zcat individual files. Before I start testing the restore,
does anyone see anything wrong in my thinking?

--- BackupPC_tarCreate 2008-12-06 12:44:28.000000000 +0100
+++ BackupPC_tarCreate_noDecompress 2009-08-19 09:16:38.000000000 +0200
@@ -462,17 +462,17 @@
#
# Regular file: write the header and file
#
- my $f = BackupPC::FileZIO->open($hdr->{fullPath}, 0, $hdr->{compress});
- if ( !defined($f) ) {
+ if ( ! open (IN, "<", $hdr->{fullPath})) {
print(STDERR "Unable to open file $hdr->{fullPath}\n");
$ErrorCnt++;
return;
}
+ $hdr->{size} = -s $hdr->{fullPath};
TarWriteFileInfo($fh, $hdr);
if ( $opts{l} || $opts{L} ) {
$size = $hdr->{size};
} else {
- while ( $f->read(\$data, $BufSize) > 0 ) {
+ while ( read(IN, $data, $BufSize) > 0 ) {
if ( $size + length($data) > $hdr->{size} ) {
print(STDERR "Error: truncating $hdr->{fullPath} to"
. " $hdr->{size} bytes\n");
@@ -482,7 +482,7 @@
TarWrite($fh, \$data);
$size += length($data);
}
- $f->close;
+ close IN;
if ( $size != $hdr->{size} ) {
print(STDERR "Error: padding $hdr->{fullPath} to $hdr->{size}"
. " bytes from $size bytes\n");

Loading...