Add support for multiple S3 targets per backup job - #492
Open
cfoellmann wants to merge 1 commit into
Open
Conversation
Backup jobs could only ever be uploaded to a single S3 endpoint. Mirroring a backup to a second provider meant either a second backup job dumping the same database twice, or a hand written post script that reimplements the upload, the checksum handling and the retention. S3_TARGETS takes a comma separated list of target names and uploads the very same dump and checksum file to each of them, so all endpoints hold identical content. Every S3 option exists per target as S3_<TARGET>_<OPTION> and per job as DB01_S3_<TARGET>_<OPTION>, falling back to the existing single target variables for everything a target does not override - so shared settings stay written once. _FILE secrets work for the per target variables as well. Leaving S3_TARGETS unset keeps the previous behaviour untouched: the target list then holds a single empty entry and the existing S3_ variables are used. Every target is attempted even after an earlier one failed, so a broken endpoint no longer keeps the healthy ones from receiving their backup. A failure names the target in the log and is aggregated into move_exit_code, which already drives the failure notification and reaches post scripts as $11. The S3 retention pass loops over the same targets. It now builds its own aws-cli environment per target instead of relying on the credentials, endpoint URL and TLS flags left behind by the preceding upload. Verified against two MinIO endpoints with the container image: identical sha256 on both targets, a stopped endpoint reported as an error while the healthy target still received the backup, retention deleting on both targets, and an unchanged single target configuration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A backup job can only be uploaded to a single S3 endpoint. Mirroring a backup to a second provider currently means either running a second job that dumps the same database again, or a hand written post script that reimplements the upload, the checksum handling and the retention.
What
S3_TARGETStakes a comma separated list of target names and uploads the very same dump and checksum file to each of them, so all endpoints hold identical content.Every S3 option exists per target as
S3_<TARGET>_<OPTION>and per job asDB01_S3_<TARGET>_<OPTION>. The value used for a target is the first one that is set of:DB01_S3_<TARGET>_<OPTION>→S3_<TARGET>_<OPTION>→DB01_S3_<OPTION>→S3_<OPTION>→DEFAULT_S3_<OPTION>so shared settings are written once and only what differs is repeated per target.
_FILEsecrets work for the per target variables as well.Behaviour
S3_TARGETSunset the target list holds a single empty entry and the existingS3_variables are used, exactly as before.move_exit_code, which already drives the failure notification and reaches post scripts as$11.aws-clibefore it gives up, which can stall a job for minutes. This is documented, withS3_<TARGET>_EXTRA_OPTS: --cli-connect-timeout 10 --cli-read-timeout 30as the remedy.Testing
Verified with the released container image against two MinIO endpoints using different bucket names:
sha256for the dump on both targets, checksum file on bothFailed moving backup to S3 Bucket - target 'minio2' - exit code 1while the healthy target still received the backupAlso included: README documentation, a
examples/multiple-s3-targets/compose.yml, and a CHANGELOG entry.Note
This branch is independent of my two other PRs and can be merged in any order.