diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 87067244cf..6b45001385 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -45,6 +45,15 @@ + + + + + + +

Reorder info command text output so most recent backup is output last.

+
+

Change file ownership only when required.

@@ -6122,6 +6131,11 @@ rdunklau + + Ryan Lambert + rustprooflabs + + Sarah Conway xenophenes diff --git a/lib/pgBackRest/Info.pm b/lib/pgBackRest/Info.pm index 02fc1b97f2..4c5e7e2eaa 100644 --- a/lib/pgBackRest/Info.pm +++ b/lib/pgBackRest/Info.pm @@ -192,13 +192,14 @@ sub formatText # Output stanza name and status $strOutput .= (defined($strOutput) ? "\n" : '') . $self->formatTextStanza($oStanzaInfo) . "\n"; - # Initialize the flag to indicate the first DB in the INFO_BACKUP_SECTION_DB is the current database - my $bDbCurrent = true; + # Get the current DB info (always last element in the array) + my $hDbCurrent = @{$oStanzaInfo->{&INFO_BACKUP_SECTION_DB}}[-1]; - # Loop through the DB history array for the stanza from newest to oldest - foreach my $hDbInfo (reverse @{$oStanzaInfo->{&INFO_BACKUP_SECTION_DB}}) + # Loop through the DB history array for the stanza from oldest to newest + foreach my $hDbInfo (@{$oStanzaInfo->{&INFO_BACKUP_SECTION_DB}}) { - if ($bDbCurrent) + + if ($hDbInfo->{&INFO_HISTORY_ID} == $hDbCurrent->{&INFO_HISTORY_ID}) { $strOutput .= "\n db (current)"; } @@ -237,7 +238,7 @@ sub formatText if (defined($strOutputArchive) || defined($strOutputBackup)) { - if (!$bDbCurrent) + if ($hDbInfo->{&INFO_HISTORY_ID} != $hDbCurrent->{&INFO_HISTORY_ID}) { $strOutput .= "\n db (prior)"; } @@ -252,8 +253,6 @@ sub formatText $strOutput .= $strOutputBackup; } } - - $bDbCurrent = false; } } diff --git a/src/command/info/info.c b/src/command/info/info.c index 81b7359e60..443eefa711 100644 --- a/src/command/info/info.c +++ b/src/command/info/info.c @@ -412,8 +412,8 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr) VariantList *archiveSection = kvGetList(stanzaInfo, varNewStr(KEY_ARCHIVE_STR)); VariantList *backupSection = kvGetList(stanzaInfo, varNewStr(STANZA_KEY_BACKUP_STR)); - // For each database find the corresponding archive and backup info - for (unsigned int dbIdx = 0; dbIdx < varLstSize(dbSection); dbIdx++) + // For each database (working from oldest to newest) find the corresponding archive and backup info + for (unsigned int dbIdx = varLstSize(dbSection) - 1; (int)dbIdx >= 0; dbIdx--) { KeyValue *pgInfo = varKv(varLstGet(dbSection, dbIdx)); uint64_t dbId = varUInt64(kvGet(pgInfo, varNewStr(DB_KEY_ID_STR))); diff --git a/src/perl/embed.auto.c b/src/perl/embed.auto.c index 7514c0c49f..d24f77ba56 100644 --- a/src/perl/embed.auto.c +++ b/src/perl/embed.auto.c @@ -10484,11 +10484,12 @@ static const EmbeddedModule embeddedModule[] = "\n" "$strOutput .= (defined($strOutput) ? \"\\n\" : '') . $self->formatTextStanza($oStanzaInfo) . \"\\n\";\n" "\n\n" - "my $bDbCurrent = true;\n" + "my $hDbCurrent = @{$oStanzaInfo->{&INFO_BACKUP_SECTION_DB}}[-1];\n" "\n\n" - "foreach my $hDbInfo (reverse @{$oStanzaInfo->{&INFO_BACKUP_SECTION_DB}})\n" + "foreach my $hDbInfo (@{$oStanzaInfo->{&INFO_BACKUP_SECTION_DB}})\n" "{\n" - "if ($bDbCurrent)\n" + "\n" + "if ($hDbInfo->{&INFO_HISTORY_ID} == $hDbCurrent->{&INFO_HISTORY_ID})\n" "{\n" "$strOutput .= \"\\n db (current)\";\n" "}\n" @@ -10525,7 +10526,7 @@ static const EmbeddedModule embeddedModule[] = "\n" "if (defined($strOutputArchive) || defined($strOutputBackup))\n" "{\n" - "if (!$bDbCurrent)\n" + "if ($hDbInfo->{&INFO_HISTORY_ID} != $hDbCurrent->{&INFO_HISTORY_ID})\n" "{\n" "$strOutput .= \"\\n db (prior)\";\n" "}\n" @@ -10540,8 +10541,6 @@ static const EmbeddedModule embeddedModule[] = "$strOutput .= $strOutputBackup;\n" "}\n" "}\n" - "\n" - "$bDbCurrent = false;\n" "}\n" "}\n" "\n\n" diff --git a/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm b/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm index ae272db10a..8a13d71271 100644 --- a/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm @@ -346,6 +346,12 @@ sub run $hyStanza = $oInfo->stanzaList($self->stanza()); $self->testResult(sub {$oInfo->formatText($hyStanza)}, "stanza: db\n status: ok\n cipher: none\n" . + "\n db (prior)\n" . + " full backup: 20161206-155728F\n" . + " timestamp start/stop: 2016-12-06 15:57:28 / 2016-12-06 15:57:28\n" . + " wal start/stop: n/a\n" . + " database size: 0B, backup size: 0B\n" . + " repository size: 0B, repository backup size: 0B\n" . "\n db (current)\n" . " wal archive min/max (9.5-2): 000000010000000000000000 / 000000010000000000000003\n\n" . " full backup: 20161207-155728F\n" . @@ -357,12 +363,6 @@ sub run " timestamp start/stop: 2016-12-08 15:57:28 / 2016-12-08 15:57:28\n" . " wal start/stop: 000000010000000000000002 / 000000010000000000000002\n" . " database size: 0B, backup size: 0B\n" . - " repository size: 0B, repository backup size: 0B\n" . - "\n db (prior)\n" . - " full backup: 20161206-155728F\n" . - " timestamp start/stop: 2016-12-06 15:57:28 / 2016-12-06 15:57:28\n" . - " wal start/stop: n/a\n" . - " database size: 0B, backup size: 0B\n" . " repository size: 0B, repository backup size: 0B\n", "formatText() multiple DB versions"); diff --git a/test/src/module/command/infoTest.c b/test/src/module/command/infoTest.c index a9f96a0ecd..3bf3c14042 100644 --- a/test/src/module/command/infoTest.c +++ b/test/src/module/command/infoTest.c @@ -327,9 +327,6 @@ testRun(void) " status: ok\n" " cipher: none\n" "\n" - " db (current)\n" - " wal archive min/max (9.4-3): none present\n" - "\n" " db (prior)\n" " wal archive min/max (9.4-1): 000000010000000000000002/000000020000000000000003\n" "\n" @@ -338,6 +335,9 @@ testRun(void) " wal start/stop: n/a\n" " database size: 25.7MB, backup size: 25.7MB\n" " repository size: 3MB, repository backup size: 3KB\n" + "\n" + " db (current)\n" + " wal archive min/max (9.4-3): none present\n" ,"text - single stanza, valid backup, no priors, no archives in latest DB"); // backup.info/archive.info files exist, backups exist, archives exist @@ -632,9 +632,6 @@ testRun(void) " status: ok\n" " cipher: none\n" "\n" - " db (current)\n" - " wal archive min/max (9.5-2): none present\n" - "\n" " db (prior)\n" " wal archive min/max (9.4-1): 000000010000000000000002/000000020000000000000003\n" "\n" @@ -658,6 +655,9 @@ testRun(void) " repository size: 2.3MB, repository backup size: 346B\n" " backup reference list: 20181119-152138F, 20181119-152138F_20181119-152152D\n" "\n" + " db (current)\n" + " wal archive min/max (9.5-2): none present\n" + "\n" "stanza: stanza2\n" " status: error (no valid backups)\n" " cipher: none\n"