diff --git a/docs/usage/delete-backup.md b/docs/usage/delete-backup.md index c9a72c02..3d37e25b 100644 --- a/docs/usage/delete-backup.md +++ b/docs/usage/delete-backup.md @@ -1,16 +1,12 @@ # Delete backups -To limit the amount of space for old backups on the backup storage, you need to delete these backups periodically. You can do this in the following ways: +Use [`pbm delete-backup`](../reference/pbm-commands.md#pbm-delete-backup) to delete backup snapshots and [`pbm delete-pitr`](../reference/pbm-commands.md#pbm-delete-pitr) to delete point-in-time recovery oplog slices. Use the `pbm cleanup --older-than` command to [automate backup storage cleanup](schedule-backup.md#backup-storage-cleanup). -- [delete backup snapshots and point-in-time recovery oplog slices simultaneously](#clean-up-outdated-data). This way you can [automate storage cleanup](schedule-backup.md#backup-storage-cleanup). -- [delete backup snapshots](#delete-backup-snapshots) and [point-in-time oplog slices](#delete-oplog-slices) separately. This gives you more control over the deletion flow. However, these are manual operations. - - -## Clean up outdated data +## Delete outdated data !!! admonition "Version added: [2.1.0](../release-notes/2.1.0.md)" -To delete both outdated backup snapshots and point-in-time recovery oplog slices, use the [`pbm cleanup --older-than`](../reference/pbm-commands.md#pbm-cleanup) command. This simplifies the [automation of the backup rotation](schedule-backup.md#backup-storage-cleanup). +You can use the `pbm cleanup --older-than` command to delete both outdated backup snapshots and point-in-time recovery oplog slices. This simplifies the [automation of the backup rotation](schedule-backup.md#backup-storage-cleanup). The timestamp you specify for the `--older-than` flag must be in the following format: @@ -97,32 +93,44 @@ Here's how the cleanup works: 1. You can only delete a backup that is not running (has the “done” or the “error” state). To check the backup state, run the [`pbm status`](../reference/pbm-commands.md#pbm-status) command. -2. To ensure oplog continuity for [point-in-time restore](pitr-tutorial.md), the `pbm delete-backup` command deletes any backup(s) except the following: +2. You can only delete the whole incremental backup chain, not a single increment. When you specify the increment name of the timestamp for a single increment, the backup deletion fails. - * A backup snapshot that can serve as the base for any point-in-time recovery and has point-in-time recovery time ranges deriving from it. To delete such a backup, first [delete the oplog slices](#delete-oplog-slices) that are created after the `restore-to time` value for this backup. +3. To ensure oplog continuity for [point-in-time restore](pitr-tutorial.md), the `pbm delete-backup` command deletes any backup(s) except the following: - * The most recent backup if point-in-time recovery is enabled and there are no oplog slices following this backup yet. + === "Version 2.4.0 and higher" - To illustrate this, let’s take the following `pbm list` output: + The most recent backup snapshot (logical, physical, base incremental) that can serve as the base for point-in-time recovery, if it is enabled. - ```{.bash .no-copy} - Backup snapshots: - 2022-10-05T14:13:50Z [restore_to_time: 2022-10-05T14:13:55Z] - 2022-10-06T14:52:42Z [restore_to_time: 2022-10-06T14:52:47Z] - 2022-10-07T14:57:17Z [restore_to_time: 2022-10-07T14:57:22Z] - PITR : - 2022-10-05T14:13:56Z - 2022-10-05T18:52:21Z - ``` + === "Version 2.3.1 and earlier" + + * A backup snapshot that can serve as the base for any point-in-time recovery and has point-in-time recovery time ranges deriving from it. To delete such a backup, first [delete the oplog slices](#delete-oplog-slices) that are created after the `restore-to time` value for this backup. + + * The most recent backup if point-in-time recovery is enabled and there are no oplog slices following this backup yet. + + To illustrate this, let’s take the following `pbm list` output: + + ```{.bash .no-copy} + Backup snapshots: + 2022-10-05T14:13:50Z [restore_to_time: 2022-10-05T14:13:55Z] + 2022-10-06T14:52:42Z [restore_to_time: 2022-10-06T14:52:47Z] + 2022-10-07T14:57:17Z [restore_to_time: 2022-10-07T14:57:22Z] + + PITR : + 2022-10-05T14:13:56Z - 2022-10-05T18:52:21Z + ``` - You can delete a backup `2022-10-06T14:52:42Z` since it has no point-in-time oplog slices. You cannot delete the following backups: + You can delete a backup `2022-10-06T14:52:42Z` since it has no point-in-time oplog slices. You cannot delete the following backups: + + - `2022-10-05T14:13:50Z` because it is the base for recovery to any point in time from the PITR time range `2022-10-05T14:13:56Z - 2022-10-05T18:52:21Z` + - `2022-10-07T14:57:17Z` because PITR is enabled and there are no oplog slices following it yet. + +4. Starting with version 2.0.4, you can delete any backup snapshot (except the most recent one with point-in-time recovery enabled) regardless the point-in-time recovery slices deriving from it. Such slices are then marked as "no base backup" in the `pbm status` output. - - `2022-10-05T14:13:50Z` because it is the base for recovery to any point in time from the PITR time range `2022-10-05T14:13:56Z - 2022-10-05T18:52:21Z` - - `2022-10-07T14:57:17Z` because PITR is enabled and there are no oplog slices following it yet. ### Behavior -You can delete either a specified backup snapshot or backup snapshots created before the specified time. Starting with version 2.0.0, you can delete [selective backups](../features/selective-backup.md). Starting with version [2.4.0](../release-notes/2.4.0.md), you can delete backups by type; for example, delete all physical backups that are older than the specified time. +You can delete either a specified backup snapshot or all backup snapshots older than the specified time. Starting with version 2.0.0, you can also delete [selective backups](../features/selective-backup.md). === "A specific backup" @@ -170,62 +178,8 @@ You can delete either a specified backup snapshot or backup snapshots created be 2021-04-21T02:16:33Z ``` -=== "Specific types of backups" - - To delete backups of a specific type that were created before the specified time, run the `pbm delete backup` with the `--type` and the `--older-than` flags. PBM deletes all backups that don't serve as the base for restore to the specified timestamp. - - Note that you must specify both flags to delete backups of the desired type. - - #### Example - - You have the following list of backups: - - ```{.text .no-copy} - Backups: - Snapshots: - 2024-02-26T10:11:05Z 905.92MB [restore_to_time: 2024-02-26T10:11:07Z] - 2024-02-26T10:06:57Z 86.99MB [restore_to_time: 2024-02-26T10:07:00Z] - 2024-02-26T10:03:24Z 234.12MB [restore_to_time: 2024-02-26T10:03:26Z] - 2024-02-26T10:00:16Z 910.27MB [restore_to_time: 2024-02-26T10:00:18Z] - 2024-02-26T09:56:18Z 961.68MB [restore_to_time: 2024-02-26T09:56:20Z] - 2024-02-26T08:43:44Z 86.83MB [restore_to_time: 2024-02-26T08:43:47Z] - PITR chunks [8.25MB]: - 2024-02-26T08:43:48Z - 2024-02-26T10:17:21Z - ``` - - You wish to delete all physical backups that are older than 10:00 a.m. - - ``` - $ pbm delete-backup --older-than="2024-02-26T10:00:00" -t physical -y - ``` - - There are two physical backup snapshots, but only `2024-02-26T09:56:18Z 961.68MB [restore_to_time: 2024-02-26T09:56:20Z]` snapshot passes in the specified timestamp. Therefore, PBM deletes this one only: - - ```{.text .no-copy} - Snapshots: - - "2024-02-26T09:56:18Z" [size: 961.68MB type: , restore time: 2024-02-26T09:56:20Z] - Waiting for delete to be done .[done] - ``` - - The resulting list of backups looks like this: - - ```{.text .no-copy} - Backups: - Snapshots: - 2024-02-26T10:11:05Z 905.92MB [restore_to_time: 2024-02-26T10:11:07Z] - 2024-02-26T10:06:57Z 86.99MB [restore_to_time: 2024-02-26T10:07:00Z] - 2024-02-26T10:03:24Z 234.12MB [restore_to_time: 2024-02-26T10:03:26Z] - 2024-02-26T10:00:16Z 910.27MB [restore_to_time: 2024-02-26T10:00:18Z] - 2024-02-26T08:43:44Z 86.83MB [restore_to_time: 2024-02-26T08:43:47Z] - PITR chunks [8.73MB]: - 2024-02-26T08:43:48Z - 2024-02-26T10:17:21Z - ``` - - In the same way you can delete other types of snapshots. - - -By default, the ``pbm delete-backup`` command asks for your confirmation to proceed with the deletion. To bypass it, add the `-y` or - `--yes` flag. +By default, the ``pbm delete-backup`` command asks for your confirmation to proceed with the deletion. To bypass it, add the `-f` or + `--force` flag. ```{.bash data-prompt="$"} $ pbm delete-backup --force 2021-04-20T13:45:59Z @@ -269,6 +223,3 @@ To view oplog slices, run the [`pbm list`](../reference/pbm-commands.md#pbm-list ``` To enable [point-in-time recovery](pitr-tutorial.md) from the most recent backup snapshot, Percona Backup for MongoDB does not delete slices that were made after that snapshot. For example, if the most recent snapshot is `2021-07-20T07:05:23Z [restore_to_time: 2021-07-21T07:05:44]` and you specify the timestamp `2021-07-20T07:05:44`, Percona Backup for MongoDB deletes only slices that were made before `2021-07-20T07:05:23Z`. - -To verify what oplog slices will be deleted without yet deleting them, run the ``pbm delete-pitr`` command with the `--dry-run` flag. -