X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2FBackupPC%2FStorage.pm;h=0d066e5f1bf6b375ff3b5eaa2d160f0d9d7e7f18;hb=523fdef21f0ca0d691a0b8c95ca76b18a1adb60a;hp=7d142f63f95a671ea55e188628624eff58eddcfb;hpb=fad8dd470868fb4db332cb8214852783e8c6e75b;p=BackupPC.git diff --git a/lib/BackupPC/Storage.pm b/lib/BackupPC/Storage.pm index 7d142f6..0d066e5 100644 --- a/lib/BackupPC/Storage.pm +++ b/lib/BackupPC/Storage.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0, released 20 Jun 2004. +# Version 3.0.0alpha, released 23 Jan 2006. # # See http://backuppc.sourceforge.net. # @@ -39,6 +39,7 @@ package BackupPC::Storage; use strict; use BackupPC::Storage::Text; +use Data::Dumper; sub new { @@ -51,6 +52,7 @@ sub new xferErrs xferBadFile xferBadShare tarErrs compress sizeExistComp sizeNewComp noFill fillFromNum mangle xferMethod level + charset )], RestoreFields => [qw( num startTime endTime result errorMsg nFiles size @@ -64,4 +66,24 @@ sub new return BackupPC::Storage::Text->new($flds, $paths, @_); } +# +# Writes per-backup information into the pc/nnn/backupInfo +# file to allow later recovery of the pc/backups file in +# cases when it is corrupted. +# +sub backupInfoWrite +{ + my($class, $pcDir, $bkupNum, $bkupInfo, $force) = @_; + + return if ( !$force && -f "$pcDir/$bkupNum/backupInfo" ); + my($dump) = Data::Dumper->new( + [ $bkupInfo], + [qw(*backupInfo)]); + $dump->Indent(1); + if ( open(BKUPINFO, ">", "$pcDir/$bkupNum/backupInfo") ) { + print(BKUPINFO $dump->Dump); + close(BKUPINFO); + } +} + 1;