Closed gcalacoci closed 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.
(We also need unit tests)
This PR adds a couple of fields to the
backup.info
:parent_backup_id
: stores the ID of the parent backup when taking an incremental backup throughpg_basebackup
;children_backup_ids
: stores a list of IDs of the backups which are incremental of this backup.That information is updated by the backup manager whenever a backup is executed with
parent_backup_id
parameter set, which indicates this is apg_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:get_backup_manifest_path
: the manifest of the parent backup is required bypg_basebackup
when taking incremental backups. This method is handy for getting the path to that file;get_parent_backup_info
: gets the backup info object of the parent backup of this backup. Makes it easier to take incremental backups and to update the relationships;get_child_backup_info
: gets the backup info object of a child backup of this backup. Will make it easier to remove backups and apply the retention policies.With all that in mind, we also applied a small refactoring of the
backup
andbackup_copy
methods. They used to usekwargs
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 passingLocalBackupInfo
objects through all functions and methods -- we can easily retrieve them ay any point by using the helper methods listed above.References: BAR-165.