From 0d5a1eaf9efc3e051221cc32b373139cc1a274a6 Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 7 Sep 2016 07:20:07 -0400 Subject: [PATCH] The archive-start and archive-stop settings are now filled in backup.manifest. --- doc/xml/release.xml | 4 ++++ lib/pgBackRest/Backup.pm | 40 +++++++++++++++++----------------------- lib/pgBackRest/Db.pm | 10 ++++++---- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 0edb8f2e4..d827d7e2f 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -139,6 +139,10 @@

Exclude contents of $PGDATA/pg_replslot directory so that replication slots on the master do not become part of the backup.

+ +

The archive-start and archive-stop settings are now filled in backup.manifest even when archive-check-n.

+
+

Experimental support for non-exclusive backups in 9.6 rc1. Changes to the control/catalog/WAL versions in subsequent betas may break compatibility but will be updated with each release to keep pace.

diff --git a/lib/pgBackRest/Backup.pm b/lib/pgBackRest/Backup.pm index 0321004cd..63698445b 100644 --- a/lib/pgBackRest/Backup.pm +++ b/lib/pgBackRest/Backup.pm @@ -662,9 +662,10 @@ sub process } # Start backup (unless --no-online is set) - my $strArchiveStart; - my $oTablespaceMap; - my $oDatabaseMap; + my $strArchiveStart = undef; + my $strLsnStart = undef; + my $oTablespaceMap = undef; + my $oDatabaseMap = undef; # Don't start the backup but do check if PostgreSQL is running if (!optionGet(OPTION_ONLINE)) @@ -688,13 +689,14 @@ sub process else { # Start the backup - ($strArchiveStart) = + ($strArchiveStart, $strLsnStart) = $oDbMaster->backupStart( BACKREST_NAME . ' backup started at ' . timestampFormat(undef, $lTimestampStart), optionGet(OPTION_START_FAST)); # Record the archive start location - $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_LSN_START, undef, $strArchiveStart); - &log(INFO, "backup lsn start: ${strArchiveStart}"); + $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_START, undef, $strArchiveStart); + $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_LSN_START, undef, $strLsnStart); + &log(INFO, "backup start archive = ${strArchiveStart}, lsn = ${strLsnStart}"); # Get tablespace map $oTablespaceMap = $oDbMaster->tablespaceMapGet(); @@ -710,9 +712,9 @@ sub process $oDbStandby->configValidate(); - &log(INFO, "wait for replay on the standby to reach ${strArchiveStart}"); + &log(INFO, "wait for replay on the standby to reach ${strLsnStart}"); - my ($strReplayedLSN, $strCheckpointLSN) = $oDbStandby->replayWait($strArchiveStart); + my ($strReplayedLSN, $strCheckpointLSN) = $oDbStandby->replayWait($strLsnStart); &log( INFO, @@ -858,14 +860,16 @@ sub process &log(INFO, "${strType} backup size = " . fileSizeFormat($lBackupSizeTotal)); # Stop backup (unless --no-online is set) - my $strArchiveStop; + my $strArchiveStop = undef; + my $strLsnStop = undef; if (optionGet(OPTION_ONLINE)) { - ($strArchiveStop, my $strTimestampDbStop, my $oFileHash) = $oDbMaster->backupStop(); + ($strArchiveStop, $strLsnStop, my $strTimestampDbStop, my $oFileHash) = $oDbMaster->backupStop(); - $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_LSN_STOP, undef, $strArchiveStop); - &log(INFO, 'backup lsn stop: ' . $strArchiveStop); + $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_STOP, undef, $strArchiveStop); + $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_LSN_STOP, undef, $strLsnStop); + &log(INFO, "backup stop archive = ${strArchiveStop}, lsn = ${strLsnStop}"); # Write out files returned from stop backup foreach my $strFile (sort(keys(%{$oFileHash}))) @@ -912,7 +916,7 @@ sub process logDebugMisc($strOperation, "retrieve archive logs ${strArchiveStart}:${strArchiveStop}"); my $oArchive = new pgBackRest::Archive(); my $strArchiveId = $oArchive->getArchiveId($oFileLocal); - my @stryArchive = lsnFileRange($strArchiveStart, $strArchiveStop, $strDbVersion); + my @stryArchive = lsnFileRange($strLsnStart, $strLsnStop, $strDbVersion); foreach my $strArchive (@stryArchive) { @@ -920,16 +924,6 @@ sub process $oArchive->walFileName($oFileLocal, $strArchiveId, $strArchive, false, optionGet(OPTION_ARCHIVE_TIMEOUT)); $strArchive = substr($strArchiveFile, 0, 24); - if (!$oBackupManifest->test(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_START)) - { - $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_START, undef, $strArchive); - $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_STOP, undef, $strArchive); - } - else - { - $oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_STOP, undef, $strArchive); - } - if (optionGet(OPTION_BACKUP_ARCHIVE_COPY)) { logDebugMisc($strOperation, "archive: ${strArchive} (${strArchiveFile})"); diff --git a/lib/pgBackRest/Db.pm b/lib/pgBackRest/Db.pm index b60b65852..5f17494a7 100644 --- a/lib/pgBackRest/Db.pm +++ b/lib/pgBackRest/Db.pm @@ -673,8 +673,8 @@ sub backupStart "exclusive pg_start_backup() with label \"${strLabel}\": backup begins after " . ($bStartFast ? "the requested immediate checkpoint" : "the next regular checkpoint") . " completes"); - my ($strTimestampDbStart, $strArchiveStart) = $self->executeSqlRow( - "select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US TZ'), lsn::text" . + my ($strTimestampDbStart, $strArchiveStart, $strLsnStart) = $self->executeSqlRow( + "select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US TZ'), pg_xlogfile_name(lsn), lsn::text" . " from pg_start_backup('${strLabel}'" . ($bStartFast ? ', true' : $self->{strDbVersion} >= PG_VERSION_84 ? ', false' : '') . ($self->{strDbVersion} >= PG_VERSION_96 ? ', false' : '') . ') as lsn'); @@ -684,6 +684,7 @@ sub backupStart ( $strOperation, {name => 'strArchiveStart', value => $strArchiveStart}, + {name => 'strLsnStart', value => $strLsnStart}, {name => 'strTimestampDbStart', value => $strTimestampDbStart} ); } @@ -702,9 +703,9 @@ sub backupStop &log(INFO, 'execute ' . ($self->{strDbVersion} >= PG_VERSION_96 ? 'non-' : '') . 'exclusive pg_stop_backup() and wait for all WAL segments to archive'); - my ($strTimestampDbStop, $strArchiveStop, $strLabel, $strTablespaceMap) = + my ($strTimestampDbStop, $strArchiveStop, $strLsnStop, $strLabel, $strTablespaceMap) = $self->executeSqlRow( - "select to_char(clock_timestamp(), 'YYYY-MM-DD HH24:MI:SS.US TZ'), lsn::text, " . + "select to_char(clock_timestamp(), 'YYYY-MM-DD HH24:MI:SS.US TZ'), pg_xlogfile_name(lsn), lsn::text, " . ($self->{strDbVersion} >= PG_VERSION_96 ? 'labelfile, spcmapfile' : "null as labelfile, null as spcmapfile") . ' from pg_stop_backup(' . ($self->{strDbVersion} >= PG_VERSION_96 ? 'false)' : ') as lsn')); @@ -721,6 +722,7 @@ sub backupStop ( $strOperation, {name => 'strArchiveStop', value => $strArchiveStop}, + {name => 'strLsnStop', value => $strLsnStop}, {name => 'strTimestampDbStop', value => $strTimestampDbStop}, {name => 'oFileHash', value => $oFileHash} );