X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_link;h=c1a5604ed488a8dc3ae675670f6cb2702dfb2c9c;hp=fa014e7d1aaeb49c884192670829fa01aa1c3b02;hb=ca593f66fd6c35764bd8997c6338b781330f019c;hpb=8a5f496e93ee77491746cb72ef9949ab91c82dae diff --git a/bin/BackupPC_link b/bin/BackupPC_link index fa014e7..c1a5604 100755 --- a/bin/BackupPC_link +++ b/bin/BackupPC_link @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/usr/bin/perl #============================================================= -*-perl-*- # # BackupPC_link: link new backup into pool @@ -21,7 +21,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001 Craig Barratt +# Copyright (C) 2001-2009 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -39,17 +39,19 @@ # #======================================================================== # -# Version 2.0.0_CVS, released 18 Jan 2003. +# Version 3.2.0beta1, released 10 Jan 2010. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use lib "/usr/local/BackupPC/lib"; use BackupPC::Lib; use BackupPC::Attrib; use BackupPC::PoolWrite; +use BackupPC::Storage; use File::Find; use File::Path; @@ -106,11 +108,23 @@ while ( 1 ) { $CurrDumpDir = "$Dir/$Backups[$num]{num}"; $Compress = $Backups[$num]{compress}; if ( open(NEW, "<", "$Dir/NewFileList.$Backups[$num]{num}") ) { + my(@shareAttribArgs); + binmode(NEW); while ( ) { chomp; next if ( !/(\w+) (\d+) (.*)/ ); - LinkNewFile($1, $2, "$CurrDumpDir/$3"); + if ( $3 eq "attrib" ) { + # + # Defer linking top-level attrib file until the end + # since it can appear multiple times when multiple shares + # are dumped. + # + @shareAttribArgs = ($1, $2, "$CurrDumpDir/$3"); + } else { + LinkNewFile($1, $2, "$CurrDumpDir/$3"); + } } + LinkNewFile(@shareAttribArgs) if ( @shareAttribArgs ); close(NEW); } unlink("$Dir/NewFileList.$Backups[$num]{num}") @@ -126,7 +140,7 @@ while ( 1 ) { # my $noFill = 1; my $fillFromNum; - if ( $Backups[$num]{type} eq "full" ) { + if ( $Backups[$num]{type} ne "incr" ) { $noFill = 0 } elsif ( $Conf{IncrFill} ) { my $i; @@ -154,6 +168,16 @@ while ( 1 ) { $Backups[$num]{sizeNewComp} += $sizeNewComp; $Backups[$num]{noFill} = $noFill; $Backups[$num]{fillFromNum} = $fillFromNum; + # + # Save just this backup's info in case the main backups file + # gets corrupted + # + BackupPC::Storage->backupInfoWrite($Dir, + $Backups[$num]{num}, + $Backups[$num], 1); + # + # Save the main backups file + # $bpc->BackupInfoWrite($host, @Backups); } @@ -209,7 +233,21 @@ sub FillIncr # # Exists in the older filled backup, and not in the new, so link it # - link($name, $newName); + my($exists, $digest, $origSize, $outSize, $errs) + = BackupPC::PoolWrite::LinkOrCopy( + $bpc, + $name, $Compress, + $newName, $Compress); + if ( $exists ) { + $nFilesExist++; + $sizeExist += $origSize; + $sizeExistComp += $outSize; + } elsif ( $outSize > 0 ) { + $nFilesNew++; + $sizeNew += $origSize; + $sizeNewComp += -s $outSize; + LinkNewFile($digest, $origSize, $newName); + } } }