Refactor database target for backups
What does this MR do and why?
This MR refactors the database target for backups to simplify the logic. It also converts the execution to use Shell::Pipeline, and improve it to use ENV variables when provided.
Refactor database target for backups
- don't check for db adapter because we have only one
- run decompression and PG restore commands in one pipeline
This MR depends on some refactoring done in !163584 (merged), so it cannot be merged until !163584 (merged) and !164205 (merged) are merged.
The MR does not include tests for the Targets::Database
class as we can only do that when it is fully is decoupled from the rails codebase via #481435.
Related issue: #494209
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Run a regular backup:
./bin/gitlab-backup-cli backup all
- Note down the backup identification, something like this:
1730476493_2024_11_01_17.6.0-pre
- Reuse it in the next command to restore from the backup:
./bin/gitlab-backup-cli restore all BACKUP_ID_FROM_BEFORE
It should successfully backup and restore.
Edited by Gabriel Mazetto