Several people have discussed creating incremental archives,
and there's the archiveme.pl script, but that creates a full
archive first and then extracts the required files out of it.
That approach isn't going to work for me.
I need a script that gets the "right" files first time.
So I modifed tarCreate as below. I now have a -m option
that allows me to specify how far back to stop collecting
files. For example, specify -m 12 -n 13 to get files only
from dumps 12 and 13.
Because every dump includes the full directory
hierarchy (so as to include the attrib files), the
result would have included zillions of empty
directories had I not commented out the code
to include directories in the output (see the
last bit of the patch).
My question: am I missing something, or
am I done?
--- /opt/BackupPC-3.1.0/bin/BackupPC_tarCreate 2008-05-13
16:13:30.000000000 +1000
+++ BackupPC_tarCreate-incr 2008-05-26 15:12:35.000000000 +1000
@@ -15,6 +15,8 @@
# -n dumpNum Dump number from which the tar archive is created.
# A negative number means relative to the end (eg -1
# means the most recent dump, -2 2nd most recent etc).
+# -m dumpNum Only go back as far as this dump to get files.
+# E.g. -m 2 -n 3 collects files only from dumps 2 and 3.
# -s shareName Share name from which the tar archive is created.
#
# Other options:
@@ -76,7 +78,7 @@
my %opts;
-if ( !getopts("Llte:h:n:p:r:s:b:w:", \%opts) || @ARGV < 1 ) {
+if ( !getopts("Llte:h:n:p:r:s:b:w:m:", \%opts) || @ARGV < 1 ) {
print STDERR <<EOF;
usage: $0 [options] files/directories...
Required options:
@@ -84,6 +86,8 @@
-n dumpNum dump number from which the tar archive is created
A negative number means relative to the end (eg -1
means the most recent dump, -2 2nd most recent etc).
+ -m dumpNum Only go back as far as this dump to get files.
+ E.g. -m 2 -n 3 collects files only from dumps 2 and 3.
-s shareName share name from which the tar archive is created
Other options:
@@ -113,6 +117,15 @@
}
my $Num = $opts{n};
+my $StopAtNum = 0;
+if ( $opts{m} ne "" ) {
+ if ( $opts{m} !~ /^(-?\d+)$/ ) {
+ print(STDERR "$0: bad dump number for -m '$opts{m}'\n");
+ exit(1);
+ }
+ $StopAtNum = $opts{m};
+}
+
my @Backups = $bpc->BackupInfoRead($Host);
my $FileCnt = 0;
my $ByteCnt = 0;
@@ -122,6 +135,24 @@
my $i;
$Num = $Backups[@Backups + $Num]{num} if ( -@Backups <= $Num && $Num < 0 );
+$StopAtNum = $Backups[0]{num} if ($StopAtNum == 0);
+$StopAtNum = $Backups[@Backups + $StopAtNum]{num} if ( -@Backups <=
$StopAtNum && $StopAtNum < 0 );
+
+if ($StopAtNum > $Num) {
+ print(STDERR "$0: argument to -m is a later backup than the
argument to -n\n");
+ exit(1);
+}
+
+# Strip away backups before $StopAtNum
+for ( $i = 0 ; $i < @Backups ; $i++ ) {
+ last if ( $Backups[$i]{num} == $StopAtNum );
+}
+if ( $i >= @Backups ) {
+ print(STDERR "$0: bad backup number -m $StopAtNum for host $Host\n");
+ exit(1);
+}
+splice (@Backups,0,$i);
+
for ( $i = 0 ; $i < @Backups ; $i++ ) {
last if ( $Backups[$i]{num} == $Num );
}
@@ -454,8 +485,8 @@
#
# Directory: just write the header
#
- $hdr->{name} .= "/" if ( $hdr->{name} !~ m{/$} );
- TarWriteFileInfo($fh, $hdr);
+# $hdr->{name} .= "/" if ( $hdr->{name} !~ m{/$} );
+# TarWriteFileInfo($fh, $hdr);
$DirCnt++;
} elsif ( $hdr->{type} == BPC_FTYPE_FILE ) {
my($data, $size);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List: https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki: http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/
|