X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FStorage.pm;h=b77e686f0b9c63dd3a497af4253ed44fdb880b7a;hp=7d142f63f95a671ea55e188628624eff58eddcfb;hb=380a4961e996464a8c19e39a5339cb3a3bff0580;hpb=fad8dd470868fb4db332cb8214852783e8c6e75b diff --git a/lib/BackupPC/Storage.pm b/lib/BackupPC/Storage.pm index 7d142f6..b77e686 100644 --- a/lib/BackupPC/Storage.pm +++ b/lib/BackupPC/Storage.pm @@ -11,7 +11,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2004 Craig Barratt +# Copyright (C) 2004-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 @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0, released 20 Jun 2004. +# Version 3.2.0, released 31 Jul 2010. # # 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 version )], 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;