Hi,

Well, finally I solved the problem of the external backup with pooled files.  I 
*know* there has to be a better way, what I'm doing takes about fourty hours to 
complete, and is just about as inefficient as it gets, but it was the only way 
I found to fit the 30+ machines in the only external drive I have with just a 
couple of hours of hacking.  I wanted to have just *one* backup of each machine 
in the removable media and not the two or three living in Backuppc.

So, the solution for you to copy or (I hope) to improve:

        - For each PC
                - get the latest backup number
                - run BackupPC_archiveHost
                - run BackupPC_tarExtract (modified to extract to external 
drive)
                - since it's going to be the only backup for this pc, rename 
./new to ./0
                - run BackupPC_link (modified to work in external drive)
                - do some cleanup tasks

As you can see I'm creating a tar file and then I'm extracting from it.  I 
don't understand the code well enough to simply copy from one pool to another.  
Ideas?  That would be a lot faster, and more logical.

Find attached the first script I wrote and the diff of the modified files:  
BackupPC_link  BackupPC_tarExtract  BackupPC_trashClean

The most important change is in the creation of $bpc, since I added there the 
path to the external drive.  I tried to find a cleaner way to do it, but I 
couldn't.

Eduardo.
diff -ru /usr/share/backuppc/bin/BackupPC_link backuppc/BackupPC_link
--- /usr/share/backuppc/bin/BackupPC_link	2005-09-21 09:01:36.000000000 -0300
+++ backuppc/BackupPC_link	2006-01-16 16:09:07.000000000 -0300
@@ -60,7 +60,7 @@
 # Initialize
 ###########################################################################
 
-die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
+die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new("/var/tmp/backuppc",undef,undef)) );
 my $TopDir = $bpc->TopDir();
 my $BinDir = $bpc->BinDir();
 my %Conf   = $bpc->Conf();
@@ -91,22 +91,22 @@
 my $md5 = Digest::MD5->new;
 my($nFilesNew, $sizeNew, $sizeNewComp);
 my($nFilesExist, $sizeExist, $sizeExistComp);
-while ( 1 ) {
-    my @Backups = $bpc->BackupInfoRead($host);
+{
     $nFilesNew = $sizeNew = $sizeNewComp = 0;
     $nFilesExist = $sizeExist = $sizeExistComp = 0;
     my($num);
-    for ( $num = 0 ; $num < @Backups ; $num++ ) {
-        last if ( $Backups[$num]{nFilesNew} eq ""
-                    || -f "$Dir/NewFileList.$Backups[$num]{num}" );
-    }
-    last if ( $num >= @Backups );
+#    for ( $num = 0 ; $num < @Backups ; $num++ ) {
+#        last if ( $Backups[$num]{nFilesNew} eq ""
+#                    || -f "$Dir/NewFileList.$Backups[$num]{num}" );
+#    }
+#    last if ( $num >= @Backups );
     #
     # Process list of new files left by BackupPC_dump
     #
-    $CurrDumpDir = "$Dir/$Backups[$num]{num}";
-    $Compress = $Backups[$num]{compress};
-    if ( open(NEW, "<", "$Dir/NewFileList.$Backups[$num]{num}") ) {
+#    $CurrDumpDir = "$Dir/$Backups[$num]{num}";
+    $CurrDumpDir = "$Dir/0";
+print "Procesando $CurrDumpDir\n";
+    if ( open(NEW, "<", "$Dir/NewFileList") ) {
 	binmode(NEW);
         while ( <NEW> ) {
             chomp;
@@ -115,48 +115,46 @@
         }
         close(NEW);
     }
-    unlink("$Dir/NewFileList.$Backups[$num]{num}")
-                if ( -f "$Dir/NewFileList.$Backups[$num]{num}" );
 
-    #
-    # See if we should fill in this dump.  We only need to fill
-    # in incremental dumps.  We can only fill in the incremental
-    # dump if there is an existing filled in dump with the same
-    # type of compression (on or off).  Eg, we can't fill in
-    # a compressed incremental if the most recent filled in dump
-    # is not compressed.
-    #
-    my $noFill = 1;
-    my $fillFromNum;
-    if ( $Backups[$num]{type} ne "incr" ) {
-        $noFill = 0
-    } elsif ( $Conf{IncrFill} ) {
-        my $i;
-        for ( $i = $num - 1 ; $i >= 0 ; $i-- ) {
-            last if ( !$Backups[$i]{noFill}
-                          && ($Backups[$i]{compress} ? 1 : 0)
-                                       == ($Compress ? 1 : 0) );
-        }
-        my $prevDump = "$Dir/$Backups[$i]{num}";
-        if ( $i >= 0 && -d $prevDump ) {
-            find({wanted => \&FillIncr, no_chdir => 1}, $prevDump);
-            $noFill = 0;
-            $fillFromNum = $Backups[$i]{num};
-        }
-    }
-    #
-    # Update the backup info file in $TopDir/pc/$host/backups
-    #
-    @Backups = $bpc->BackupInfoRead($host);
-    $Backups[$num]{nFilesExist}   += $nFilesExist;
-    $Backups[$num]{sizeExist}     += $sizeExist;
-    $Backups[$num]{sizeExistComp} += $sizeExistComp;
-    $Backups[$num]{nFilesNew}     += $nFilesNew;
-    $Backups[$num]{sizeNew}       += $sizeNew;
-    $Backups[$num]{sizeNewComp}   += $sizeNewComp;
-    $Backups[$num]{noFill}         = $noFill;
-    $Backups[$num]{fillFromNum}    = $fillFromNum;
-    $bpc->BackupInfoWrite($host, @Backups);
+#    #
+#    # See if we should fill in this dump.  We only need to fill
+#    # in incremental dumps.  We can only fill in the incremental
+#    # dump if there is an existing filled in dump with the same
+#    # type of compression (on or off).  Eg, we can't fill in
+#    # a compressed incremental if the most recent filled in dump
+#    # is not compressed.
+#    #
+#    my $noFill = 1;
+#    my $fillFromNum;
+#    if ( $Backups[$num]{type} ne "incr" ) {
+#        $noFill = 0
+#    } elsif ( $Conf{IncrFill} ) {
+#        my $i;
+#        for ( $i = $num - 1 ; $i >= 0 ; $i-- ) {
+#            last if ( !$Backups[$i]{noFill}
+#                          && ($Backups[$i]{compress} ? 1 : 0)
+#                                       == ($Compress ? 1 : 0) );
+#        }
+#        my $prevDump = "$Dir/$Backups[$i]{num}";
+#        if ( $i >= 0 && -d $prevDump ) {
+#            find({wanted => \&FillIncr, no_chdir => 1}, $prevDump);
+#            $noFill = 0;
+#            $fillFromNum = $Backups[$i]{num};
+#        }
+#    }
+#    #
+#    # Update the backup info file in $TopDir/pc/$host/backups
+#    #
+#    @Backups = $bpc->BackupInfoRead($host);
+#    $Backups[$num]{nFilesExist}   += $nFilesExist;
+#    $Backups[$num]{sizeExist}     += $sizeExist;
+#    $Backups[$num]{sizeExistComp} += $sizeExistComp;
+#    $Backups[$num]{nFilesNew}     += $nFilesNew;
+#    $Backups[$num]{sizeNew}       += $sizeNew;
+#    $Backups[$num]{sizeNewComp}   += $sizeNewComp;
+#    $Backups[$num]{noFill}         = $noFill;
+#    $Backups[$num]{fillFromNum}    = $fillFromNum;
+#    $bpc->BackupInfoWrite($host, @Backups);
 }
 
 ###########################################################################
diff -ru /usr/share/backuppc/bin/BackupPC_tarExtract backuppc/BackupPC_tarExtract
--- /usr/share/backuppc/bin/BackupPC_tarExtract	2005-09-21 09:01:36.000000000 -0300
+++ backuppc/BackupPC_tarExtract	2006-01-16 12:05:31.000000000 -0300
@@ -44,7 +44,7 @@
 
 use constant S_IFMT       => 0170000;   # type of file
 
-die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
+die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new("/var/tmp/backuppc",undef,undef)) );
 my $TopDir = $bpc->TopDir();
 my $BinDir = $bpc->BinDir();
 my %Conf   = $bpc->Conf();
diff -ru /usr/share/backuppc/bin/BackupPC_trashClean backuppc/BackupPC_trashClean
--- /usr/share/backuppc/bin/BackupPC_trashClean	2005-09-21 09:01:36.000000000 -0300
+++ backuppc/BackupPC_trashClean	2006-01-16 16:49:09.000000000 -0300
@@ -40,7 +40,7 @@
 use lib "/usr/share/backuppc/lib";
 use BackupPC::Lib;
 
-die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
+die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new("/var/tmp/backuppc",undef,undef)) );
 my $TopDir = $bpc->TopDir();
 my $BinDir = $bpc->BinDir();
 my %Conf   = $bpc->Conf();
#!/bin/bash

TEMPDIR=/var/tmp
MODIFAPPDIR=/usr/local/bin/backuppc
APPDIR=/usr/share/backuppc/bin
EXTERNALDIR=/var/tmp/backuppc
HOST=$1

# get last backup number
NUMBER=$(tail -1 /var/lib/backuppc/pc/$HOST/backups|awk '{print $1}')

echo $HOST - $NUMBER

echo "Archive ..."
# Archive
$APPDIR/BackupPC_archiveHost /usr/share/backuppc/bin/BackupPC_tarCreate /usr/bin/split /bin/true $HOST $NUMBER /bin/gzip .gz 0000000 $TEMPDIR 0 "*"

echo "Recreate pool ..."
# Recreate pool
zcat $TEMPDIR/$HOST.$NUMBER.tar.gz|$MODIFAPPDIR/BackupPC_tarExtract $HOST / 3 >> $TEMPDIR/salida
mv $EXTERNALDIR/pc/$HOST/new $EXTERNALDIR/pc/$HOST/0
$MODIFAPPDIR/BackupPC_link $HOST

echo "Clean up ..."
# Clean up
rm $TEMPDIR/$HOST.$NUMBER.tar.gz
#$MODIFAPPDIR/BackupPC_trashClean
rm -rf $EXTERNALDIR/trash/*

echo "End."

Reply via email to