From: dwsteele (@dwsteele) <noreply+dwsteele@github.com>
To: pgbackrest/pgbackrest <noreply+pgbackrest-pgbackrest@github.com>
Subject: [pgbackrest/pgbackrest] PR #2917: Add an info helper to load, cache, and save info files.
Date: Tue, 10 Nov 2026 17:47:18 +0000
Message-ID: <gh-pgbackrest-pgbackrest-2917@github.com> (raw)
Commands loaded and saved archive.info and backup.info themselves, passing the repository storage and cipher spec each time. This made it easy to get wrong, e.g. annotate loaded backup.info from the repository where the backup set was found but saved it to the default repository (fixed in b49e758f). The helper would have prevented this. Commands also had to get the repository storage before loading an info file so a remote repository could set the cipher options.
Add an info helper that loads archive.info and backup.info for a repository on first use and caches them until the configuration is loaded again. The save functions are moved to internal headers so info files are only saved through the helper, which saves to the repository the info was loaded from. The helper gets the repository storage before the cipher spec, so commands that load or save info files through the helper no longer need to. A command that runs after another in the same process, e.g. expire after backup, uses the cached info rather than loading it again.
The helper calls cfgRepoFormatSet() when backup.info is loaded, so the repository format is set for every command that loads backup.info. Previously only expire called cfgRepoFormatSet(). An option that requires a higher repository format is now reported when backup starts rather than by expire after the backup completes.
Expire and restore got the repository storage outside of the per-repository error handling, so an error getting the storage of one repository stopped the command. Now the error is handled the same as any other error for the repository: expire continues with the next repository and restore warns and selects a backup from another repository.
Replace infoBackupLoadFileReconstruct() with infoBackupReconstruct(), which reconstructs backup info that is already loaded. Add cfgInitTotal() to report how many times the configuration has been initialized, which the helper uses to detect that the configuration was loaded again, e.g. when check switches stanzas.
In unit tests a harness shim clears the cached info at the start of each test statement so each statement loads the info files from the repository. Within a statement the shim checks that cached info matches the info file each time it is accessed.