EnterpriseDB / barman

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

Maintain relationship between parent and children backups in `backup.info` #936

Closed gcalacoci closed 3 months ago

gcalacoci commented 3 months ago

This PR adds a couple of fields to the backup.info:

That information is updated by the backup manager whenever a backup is executed with parent_backup_id parameter set, which indicates this is a pg_basebackup incremental backup. When starting the new backup, its parent backup ID is immediately filled. Before finishing the backup, the list of children of its parent backup is also updated. We do that independently if the current backup succeeded or failed (we need to know who are the children so we can delete them all later if removal of the parent backup is requested, even if the children are failed backups).

Through this PR we also implemented three new methods in the LocalBackupInfo class. These are intended to make it easier to navigate through the incremental backup tree, making it easier to take incremental backups, and to later remove the backups in the tree when needed. The methods are:

With all that in mind, we also applied a small refactoring of the backup and backup_copy methods. They used to use kwargs to avoid breaking the interface of the methods as they support both Postgres and rsync based backups, and in case of Postgres both incremental and full backups. As we now have a way of navigate through backups in the incremental backup tree, we no longer need to keep passing LocalBackupInfo objects through all functions and methods -- we can easily retrieve them ay any point by using the helper methods listed above.

References: BAR-165.

barthisrael commented 3 months ago

I guess this looks to be in a good shape. I think we can work on adding the missing docstrings and/or comments. Then we can work on squashing the commits for a cleaner history. We can use the Co-authored-by: NAME <NAME@EXAMPLE.COM> syntax to both of us are assigned to the commits.

barthisrael commented 3 months ago

(We also need unit tests)