EnterpriseDB / barman

Barman - Backup and Recovery Manager for PostgreSQL
https://www.pgbarman.org/
GNU General Public License v3.0
2.14k stars 193 forks source link

Add new command line argument for `recover` command #983

Closed andremagui closed 3 months ago

andremagui commented 3 months ago

Since the introduction of incremental backups in PostgreSQL 17, we created a new recovery executor to handle the operation. The plan was to reuse the recovery_staging_path argument/configuration that was designed to recover compressed backups PR #955 . After further review, it was decided that we would create a new argument/configuration specific to recover from incremental backups called local_staging_path.

This PR:

  1. Add a new configuration option to the global/server configurations and a new command line argument for the recover command.
  2. Change the name of a method called parse_recovery_staging_path to parse_staging_path so we have a generic name to parse staging_paths and keep the same operation for both.
  3. Modify all unit tests that used parse_recovery_staging_path with the new naming.
  4. Change the implementation of the recover CLI method to accommodate the new configuration option.
  5. Modify the unit test for the recover CLI method according to the new implementation

References: BAR-269

andremagui commented 3 months ago

I thought about using the new field as an alias for the recovery_staging_path but i think it would also make things a little confusing. Let me know about other ways of implementing this if you have any ideas.

barthisrael commented 3 months ago

Posted some suggestions. Note that unit tests are failing.

barthisrael commented 3 months ago

This works as expected.

$ barman recover postgres dev_postgres_incremental ~/data_recovery
ERROR: Cannot recover from backup 'dev_postgres_incremental' of server 'postgres': backup will be combined with pg_combinebackup in the barman host but no local staging path is provided. Either set local_staging_path in the Barman config or use the --local-staging-path argument.
$ barman recover postgres dev_postgres_incremental ~/data_recovery --local-staging-path /tmp/local_staging_path
Start combining backup via pg_combinebackup for backup 20240814T182116 on /tmp/local_staging_path
End combining backup via pg_combinebackup for backup 20240814T182116
Starting local restore for server postgres using backup 20240814T182116
Destination directory: /home/vagrant/data_recovery
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.

Recovery completed (start time: 2024-08-19 12:55:40.870383+02:00, elapsed time: less than one second)
Your PostgreSQL server has been successfully prepared for recovery!
# Checked while `pg_combinebackup` was being executed
$ ls /tmp/local_staging_path/
20240814T182116
andremagui commented 3 months ago

last force-push was made because i rebased on top of master!