From: hunleyd (@hunleyd) <noreply+hunleyd@github.com>
To: pgbackrest/pgbackrest <noreply+pgbackrest-pgbackrest@github.com>
Subject: Re: [pgbackrest/pgbackrest] PR #2898: Add stanza-rekey command to change the repository passphrase.
Date: Wed, 04 Nov 2026 15:07:39 +0000
Message-ID: <gh-pgbackrest-pgbackrest-2898-rc4469270451@github.com> (raw)
In-Reply-To: <gh-pgbackrest-pgbackrest-2898@github.com>
References: <gh-pgbackrest-pgbackrest-2898@github.com>
(on src/command/stanza/rekey.c:140)
```
inline patch 1: src/command/stanza/rekey.c (+12/-11 lines) download inline-1.patchdiff --git a/src/command/stanza/rekey.c b/src/command/stanza/rekey.cindex 110a619..e2095a6 100644--- a/src/command/stanza/rekey.c+++ b/src/command/stanza/rekey.c@@ -138,33 +138,34 @@ cmdStanzaRekey(void)
// Format of the repository. stanza-upgrade saves archive.info before backup.info.
const unsigned int format = infoArchiveFormat(infoArchive);
+ // Warn when there is nothing to do. Format < 6 has a single archive key that cannot be rotated.+ if (!rekey && format < REPOSITORY_FORMAT_6)+ {+ LOG_WARN("archive key rotation requires repository format " STRINGIFY(REPOSITORY_FORMAT_6) " or higher");++ repoTotal++;+ continue;+ }+
// Check the new passphrase
if (rekey)
stanzaCipherPassCheck(repoIdx, format, "rekey a stanza");
- // Rotate the archive key. Format < 6 has a single archive key that cannot be rotated.+ // Rotate the archive key
if (format >= REPOSITORY_FORMAT_6)
{
infoArchiveCipherRotate(infoArchive, cipherSpecGen(cipherType, format), time(NULL));
LOG_INFO_FMT("rotate archive key to id %s", strZ(cipherSpecMapIdCurrent(infoArchiveCipherSpecMap(infoArchive))));
}
- // Else warn when there is nothing to do- else if (!rekey)- LOG_WARN("archive key rotation requires repository format " STRINGIFY(REPOSITORY_FORMAT_6) " or higher");
// Save the info files with the passphrase
- if (rekey || format >= REPOSITORY_FORMAT_6)- {- infoArchiveSaveFile(- infoArchive, storageRepoIdxWrite(repoIdx), INFO_ARCHIVE_PATH_FILE_STR, cfgCipherSpecMainIdx(repoIdx));- }+ infoArchiveSaveFile(infoArchive, storageRepoIdxWrite(repoIdx), INFO_ARCHIVE_PATH_FILE_STR, cipherSpecMain);
if (rekey)
{
infoBackupUpdatedSet(infoBackup);
- infoBackupSaveFile(- infoBackup, storageRepoIdxWrite(repoIdx), INFO_BACKUP_PATH_FILE_STR, cfgCipherSpecMainIdx(repoIdx));+ infoBackupSaveFile(infoBackup, storageRepoIdxWrite(repoIdx), INFO_BACKUP_PATH_FILE_STR, cipherSpecMain);
LOG_INFO("rekey info files with the new passphrase");
}
```