diff --git a/lib/BackRest/Backup.pm b/lib/BackRest/Backup.pm index 6c49e3b02..e3be0e197 100644 --- a/lib/BackRest/Backup.pm +++ b/lib/BackRest/Backup.pm @@ -1388,8 +1388,12 @@ sub backup # Create the cluster backup path $oFile->path_create(PATH_BACKUP_CLUSTER, undef, undef, true); + # Build backup tmp and config + my $strBackupTmpPath = $oFile->path_get(PATH_BACKUP_TMP); + my $strBackupConfFile = $oFile->path_get(PATH_BACKUP_TMP, 'backup.manifest'); + # Declare the backup manifest - my $oBackupManifest = new BackRest::Manifest(); + my $oBackupManifest = new BackRest::Manifest($strBackupConfFile, false); ${$oBackupManifest->{oManifest}}{'backup:option'}{'compress'} = $bCompress ? 'y' : 'n'; ${$oBackupManifest->{oManifest}}{'backup:option'}{'checksum'} = !$bNoChecksum ? 'y' : 'n'; @@ -1432,10 +1436,6 @@ sub backup ${$oBackupManifest->{oManifest}}{'backup:option'}{'hardlink'} = $bHardLink ? 'y' : 'n'; } - # Build backup tmp and config - my $strBackupTmpPath = $oFile->path_get(PATH_BACKUP_TMP); - my $strBackupConfFile = $oFile->path_get(PATH_BACKUP_TMP, 'backup.manifest'); - # Start backup (unless no-start-stop is set) ${$oBackupManifest->{oManifest}}{backup}{'timestamp-start'} = $strTimestampStart; my $strArchiveStart; @@ -1531,7 +1531,8 @@ sub backup { $bUsable = true; } - elsif ($strAbortedType eq ${$oBackupManifest->{oManifest}}{backup}{type} && $strAbortedPrior eq ${$oBackupManifest->{oManifest}}{backup}{prior}) + elsif ($strAbortedType eq ${$oBackupManifest->{oManifest}}{backup}{type} && + $strAbortedPrior eq ${$oBackupManifest->{oManifest}}{backup}{prior}) { $bUsable = true; } @@ -1569,8 +1570,8 @@ sub backup print $hVersionFile version_get(); close($hVersionFile); - # Save the backup conf file with the manifest - ini_save($strBackupConfFile, $oBackupManifest->{oManifest}); + # Save the backup manifest + $oBackupManifest->save(); # Perform the backup backup_file($strDbClusterPath, $oBackupManifest->{oManifest}); @@ -1590,8 +1591,8 @@ sub backup # consistent - at least not in this routine. if ($bArchiveRequired) { - # Save the backup conf file second time - before getting archive logs in case that fails - ini_save($strBackupConfFile, $oBackupManifest->{oManifest}); + # Save the backup manifest a second time - before getting archive logs in case that fails + $oBackupManifest->save(); # After the backup has been stopped, need to make a copy of the archive logs need to make the db consistent &log(DEBUG, "retrieving archive logs ${strArchiveStart}:${strArchiveStop}"); @@ -1648,8 +1649,8 @@ sub backup ${$oBackupManifest->{oManifest}}{backup}{'timestamp-stop'} = timestamp_string_get(); ${$oBackupManifest->{oManifest}}{backup}{label} = $strBackupPath; - # Save the backup conf file final time - ini_save($strBackupConfFile, $oBackupManifest->{oManifest}); + # Save the backup manifest final time + $oBackupManifest->save(); &log(INFO, "new backup label: ${strBackupPath}"); diff --git a/lib/BackRest/Manifest.pm b/lib/BackRest/Manifest.pm index 942977204..c683d4bc2 100644 --- a/lib/BackRest/Manifest.pm +++ b/lib/BackRest/Manifest.pm @@ -60,16 +60,24 @@ sub new { my $class = shift; # Class name my $strFileName = shift; # Filename to load manifest from + my $bLoad = shift; # Load the manifest? # Create the class hash my $self = {}; bless $self, $class; - # Create the manifest hash - $self->{oManifest} = {}; + # Filename must be specified + if (!defined($strFileName)) + { + confess &log(ASSERT, 'filename must be provided'); + } - # Load the manifest if a filename is provided - if (defined($strFileName)) + # Set variables + $self->{oManifest} = {}; + $self->{strFileName} = $strFileName; + + # Load the manifest if specified + if (!(defined($bLoad) && $bLoad == false)) { ini_load($strFileName, $self->{oManifest}); } @@ -80,18 +88,15 @@ sub new #################################################################################################################################### # SAVE # -# Save the config file. +# Save the manifest. #################################################################################################################################### -# sub save -# { -# my $self = shift; -# my $strFileName = shift; # Filename to save manifest to -# -# # Save the config file -# ini_save($strFileName, $self); -# -# return $self; -# } +sub save +{ + my $self = shift; + + # Save the config file + ini_save($self->{strFileName}, $self->{oManifest}); +} #################################################################################################################################### # GET