Aiven-Open / pghoard

PostgreSQL® backup and restore service
http://aiven-open.github.io/pghoard/
Apache License 2.0
1.3k stars 99 forks source link

Allow the restore operation to mark a backup as preserved #577

Closed kmichel-aiven closed 1 year ago

kmichel-aiven commented 1 year ago

About this change - What it does

A preserved backup won't be automatically deleted even if it matches the automatic deletion rules.

The backups following the preserved backup won't be deleted either.

This capability is enabled by passing the --preserve-until flag during restoration.

Multiple preservation requests can co-exist and be separately canceled for the same backup.

The effective preservation duration is the longest of all the uncancelled preservation requests.

If the storage is not writable and the option was enabled, pghoard will emit an error message but will not fail the restoration.

The preservation request is canceled at the end of the restore operation, only if the restoration is successful..

Why this way

The request is not renewed or extended during the backup restoration. The expectation is that the option is used with a far enough date is the future that it's not a problem.

Using a far-future date is unlikely to cause issues during normal operations since the request is canceled after a successful restore.

If needed, an operator could write a preservation request in the storage from outside pghoard, pghoard will see it and honour it

codecov[bot] commented 1 year ago

Codecov Report

Merging #577 (d219971) into main (2588f4b) will increase coverage by 0.09%. The diff coverage is 99.14%.

Additional details and impacted files [![Impacted file tree graph](https://codecov.io/gh/aiven/pghoard/pull/577/graphs/tree.svg?width=650&height=150&src=pr&token=nLr7M7hvCx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven)](https://codecov.io/gh/aiven/pghoard/pull/577?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven) ```diff @@ Coverage Diff @@ ## main #577 +/- ## ========================================== + Coverage 91.25% 91.35% +0.09% ========================================== Files 30 32 +2 Lines 4607 4671 +64 ========================================== + Hits 4204 4267 +63 - Misses 403 404 +1 ``` | [Impacted Files](https://codecov.io/gh/aiven/pghoard/pull/577?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven) | Coverage Δ | | |---|---|---| | [pghoard/object\_store.py](https://codecov.io/gh/aiven/pghoard/pull/577/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9vYmplY3Rfc3RvcmUucHk=) | `98.71% <98.71%> (ø)` | | | [pghoard/pghoard.py](https://codecov.io/gh/aiven/pghoard/pull/577/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9wZ2hvYXJkLnB5) | `84.86% <100.00%> (+0.13%)` | :arrow_up: | | [pghoard/preservation\_request.py](https://codecov.io/gh/aiven/pghoard/pull/577/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9wcmVzZXJ2YXRpb25fcmVxdWVzdC5weQ==) | `100.00% <100.00%> (ø)` | | | [pghoard/restore.py](https://codecov.io/gh/aiven/pghoard/pull/577/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9yZXN0b3JlLnB5) | `90.10% <100.00%> (-0.51%)` | :arrow_down: |