rename params to sname names as in full-text index
[BackupPC.git] / lib / BackupPC / Storage.pm
index 7d142f6..b77e686 100644 (file)
@@ -11,7 +11,7 @@
 #   Craig Barratt  <cbarratt@users.sourceforge.net>
 #
 # 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;