Aiven-Open / myhoard

MySQL Backup and Point-in-time Recovery service
Apache License 2.0
93 stars 20 forks source link

support backup preservation [BF-2219] #171

Closed kathia-barahona closed 1 year ago

kathia-barahona commented 1 year ago

About this change: What it does, why it matters

Supports request for preserving/holding a backup till a particular date, this way we can guarantee that the backup is not deleted during a restoration request.

If the oldest backup is being preserved, myhoard will not purge any backup but will keep generating new backups. Purging is resumed till the preservation date is met.

How to request a backup preservation?

For preserving a backup, a request to the HTTP API needs to be performed. For example:

PUT /backup/valid_stream_id_1234/preserve
{
    "preserve_until": "2023-09-12T13:30:00"
}

This will trigger the controller on fetching the respective backup stream and storing preserved_info.json on the object storage, it will contain the request preserve_until. After storing the file, all backups metadata are immediately refreshed and myhoard considers updated preserve_until values before trying to purge old backups.

How to cancel a backup preservation?

PUT /backup/valid_stream_id_1234/preserve
{
    "preserve_until": null,
}

This will trigger the controller on fetching the respective backup stream and storing preserved_info.json on the object storage, but will store an empty "preseve_until" value.

codecov-commenter commented 1 year ago

Codecov Report

Merging #171 (707c475) into master (9654217) will increase coverage by 0.03%. The diff coverage is 70.47%.

@@            Coverage Diff             @@
##           master     #171      +/-   ##
==========================================
+ Coverage   78.77%   78.81%   +0.03%     
==========================================
  Files          17       17              
  Lines        4400     4493      +93     
  Branches      995     1016      +21     
==========================================
+ Hits         3466     3541      +75     
- Misses        696      716      +20     
+ Partials      238      236       -2     
Files Coverage Δ
myhoard/controller.py 82.43% <89.79%> (+0.69%) :arrow_up:
myhoard/backup_stream.py 79.00% <68.42%> (-0.01%) :arrow_down:
myhoard/web_server.py 73.93% <45.94%> (-3.08%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more