From 0452383915a3efe8b5d92760af7858b2c3217a11 Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Mon, 5 Feb 2024 14:29:06 +0200 Subject: [PATCH 1/4] PBM-1141 Documented deleted backup by type modified: docs/usage/delete-backup.md modified: docs/usage/schedule-backup.md modified: mkdocs-base.yml --- docs/reference/pbm-commands.md | 6 ++++-- docs/usage/delete-backup.md | 29 +++++++++++++++++++++++++---- docs/usage/schedule-backup.md | 4 +++- mkdocs-base.yml | 4 ++-- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/docs/reference/pbm-commands.md b/docs/reference/pbm-commands.md index 78a1b89e..b0c8616e 100644 --- a/docs/reference/pbm-commands.md +++ b/docs/reference/pbm-commands.md @@ -147,7 +147,7 @@ The command accepts the following flags: ## pbm delete-backup -Deletes the specified backup snapshot or all backup snapshots that are older than the specified time. The command deletes backups that are not running regardless of the remote backup storage being used. +Deletes the specified backup snapshot or backup snapshots of one or several types that are older than the specified time. The command deletes backups that are not running regardless of the remote backup storage being used. The following is the command syntax: @@ -159,7 +159,8 @@ The command accepts the following flags: | Flag | Description | | ------------------------ | ----------------------- | -| `--older-than=TIMESTAMP` | Deletes backups older than date / time specified in the format:
- `%Y-%M-%DT%H:%M:%S` (e.g. 2020-04-20T13:13:20) or
- `%Y-%M-%D` (e.g. 2020-04-20)| +| `--older-than=TIMESTAMP` | Deletes backups older than date / time specified in the format:
- `%Y-%M-%DT%H:%M:%S` (e.g. 2023-04-20T13:13:20) or
- `%Y-%M-%D` (e.g. 2023-04-20)| +| `--type=TYPE` | Deletes backups of the specified type. Multiple values are accepted as comma-separated list. Must be used together with the `-older-than` flag. Available starting with version 2.4.0| | `--force` | Forcibly deletes backups without asking for user's confirmation | | `--yes` | Deletes backups without asking for user's confirmation | @@ -182,6 +183,7 @@ The command accepts the following flags: | `--force` | Forcibly deletes oplog slices without asking a user’s confirmation | | `-o`, `--out=json` | Shows the output as either the plain text (default) or a JSON object. Supported values: `text`, `json`. | | `--yes` | Deletes backups without asking for user's confirmation | +| `--dry-run` | Prints the list of oplog slices to be deleted without deleting them. You can use the flag to check what exactly will be deleted. Available starting with version 2.4.0. | ## pbm describe-backup diff --git a/docs/usage/delete-backup.md b/docs/usage/delete-backup.md index 5d61b859..8f46a35d 100644 --- a/docs/usage/delete-backup.md +++ b/docs/usage/delete-backup.md @@ -1,12 +1,16 @@ # Delete backups -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). +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: -## Delete outdated data +- [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 !!! admonition "Version added: [2.1.0](../release-notes/2.1.0.md)" -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). +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). The timestamp you specify for the `--older-than` flag must be in the following format: @@ -118,7 +122,7 @@ Here's how the cleanup works: ### Behavior -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). +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. === "A specific backup" @@ -166,6 +170,20 @@ You can delete either a specified backup snapshot or all backup snapshots older 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. Note that you must specify both flags to delete backups of the desired type. + + You can delete several types of backups, for example, logical and selective, by passing comma-separated values for the `--type` flag. + + PBM deletes all backups that don't serve as the base for restore to the specified timestamp. + + #### Example + + You have the following list of backups: + + + 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. @@ -211,3 +229,6 @@ 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. + diff --git a/docs/usage/schedule-backup.md b/docs/usage/schedule-backup.md index 5b1c061f..2a875854 100644 --- a/docs/usage/schedule-backup.md +++ b/docs/usage/schedule-backup.md @@ -84,7 +84,9 @@ Previous backups are not automatically removed from the backup storage. You need !!! admonition "Version added: [2.1.0](../release-notes/2.1.0.md)" -Starting with version 2.1.0, you can use the `pbm cleanup --older-than` command to delete outdated backup snapshots and point-in-time recovery oplog slices. You can configure a `cron` task to automate storage cleanup by specifying the following command in the `crontab` file: +Starting with version 2.1.0, you can use the [`pbm cleanup --older-than`](../reference/pbm-commands.md#pbm-cleanup) command to delete outdated backup snapshots and point-in-time recovery oplog slices. Learn more about how PBM deletes outdated data in the [Clean up outdated data](delete-backup.md#clean-up-outdated-data) section. + +You can configure a `cron` task to automate storage cleanup by specifying the following command in the `crontab` file: ```{.bash data-prompt="$"} $ $ /usr/bin/pbm cleanup -y --older-than 30d --wait diff --git a/mkdocs-base.yml b/mkdocs-base.yml index 374d5c89..c8b8afc1 100644 --- a/mkdocs-base.yml +++ b/mkdocs-base.yml @@ -175,7 +175,7 @@ nav: - install/backup-storage.md - install/start-pbm-agent.md - Backup and restore: - - Via the command line: +# - Via the command line: - Make a backup : "usage/start-backup.md" - Restore a backup: usage/restore.md - Make a point-in-time restore: usage/pitr-tutorial.md @@ -187,7 +187,7 @@ nav: - usage/restore-progress.md - usage/oplog-replay.md - usage/logs.md - - Via web interface: +# - Via web interface: - Backup management via PMM: pmm.md - Administer PBM: - 'Overview': manage/overview.md From bd1f4357aa0e8b2d42a74013d711fac1bf9a19b2 Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Mon, 26 Feb 2024 12:02:24 +0100 Subject: [PATCH 2/4] Added example --- docs/reference/pbm-commands.md | 6 ++-- docs/usage/delete-backup.md | 52 ++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/docs/reference/pbm-commands.md b/docs/reference/pbm-commands.md index b0c8616e..bc17556f 100644 --- a/docs/reference/pbm-commands.md +++ b/docs/reference/pbm-commands.md @@ -160,9 +160,9 @@ The command accepts the following flags: | Flag | Description | | ------------------------ | ----------------------- | | `--older-than=TIMESTAMP` | Deletes backups older than date / time specified in the format:
- `%Y-%M-%DT%H:%M:%S` (e.g. 2023-04-20T13:13:20) or
- `%Y-%M-%D` (e.g. 2023-04-20)| -| `--type=TYPE` | Deletes backups of the specified type. Multiple values are accepted as comma-separated list. Must be used together with the `-older-than` flag. Available starting with version 2.4.0| -| `--force` | Forcibly deletes backups without asking for user's confirmation | -| `--yes` | Deletes backups without asking for user's confirmation | +| `--type=TYPE` | Deletes backups of the specified type. Must be used together with the `-older-than` flag. Available starting with version 2.4.0| +| `--force` | Forcibly deletes backups without asking for user's confirmation. Deprecated. Use the `--yes` flag instead. | +| `-y`, `--yes` | Deletes backups without asking for user's confirmation | ## pbm delete-pitr diff --git a/docs/usage/delete-backup.md b/docs/usage/delete-backup.md index 8f46a35d..c9a72c02 100644 --- a/docs/usage/delete-backup.md +++ b/docs/usage/delete-backup.md @@ -172,20 +172,60 @@ You can delete either a specified backup snapshot or backup snapshots created be === "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. Note that you must specify both flags to delete backups of the desired type. + 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. - You can delete several types of backups, for example, logical and selective, by passing comma-separated values for the `--type` flag. - - 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 `-f` or - `--force` flag. +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. ```{.bash data-prompt="$"} $ pbm delete-backup --force 2021-04-20T13:45:59Z From d59286b918c640c551dba3af4cc9ce39927b571c Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Mon, 26 Feb 2024 18:12:45 +0100 Subject: [PATCH 3/4] Updated considerations --- docs/reference/pbm-commands.md | 6 +- docs/usage/delete-backup.md | 115 ++++++++++----------------------- 2 files changed, 37 insertions(+), 84 deletions(-) diff --git a/docs/reference/pbm-commands.md b/docs/reference/pbm-commands.md index bc17556f..b3df255b 100644 --- a/docs/reference/pbm-commands.md +++ b/docs/reference/pbm-commands.md @@ -163,6 +163,7 @@ The command accepts the following flags: | `--type=TYPE` | Deletes backups of the specified type. Must be used together with the `-older-than` flag. Available starting with version 2.4.0| | `--force` | Forcibly deletes backups without asking for user's confirmation. Deprecated. Use the `--yes` flag instead. | | `-y`, `--yes` | Deletes backups without asking for user's confirmation | +| `--dry-run` | Prints the list of backup snapshots to be deleted without deleting them. You can use the flag to check what exactly will be deleted. Available starting with version 2.4.0. | ## pbm delete-pitr @@ -178,12 +179,13 @@ The command accepts the following flags: | Flag | Description | | ------------------------ | ------------------------- | -| `-a`, `--all` | Deletes all oplog | +| `-a`, `--all` | Deletes all oplog slices. Deprecated. Use the `--older-than flag instead` | | `--older-than=TIMESTAMP` | Deletes oplog slices older than date / time specified in the format:
- `%Y-%M-%DT%H:%M:%S` (e.g. 2020-04-20T13:13:20) or
- `%Y-%M-%D` (e.g. 2020-04-20)

When you specify a timestamp, Percona Backup for MongoDB rounds it down to align with the completion time of the closest backup snapshot and deletes oplog slices that precede this time. Thus, extra slices remain. This is done to ensure oplog continuity. To illustrate, the PITR time range is `2021-08-11T11:16:21 - 2021-08-12T08:55:25` and backup snapshots are:

`2021-08-12T08:49:46Z 13.49MB [restore_to_time: 2021-08-12T08:50:06]`
`2021-08-11T11:36:17Z 7.37MB [restore_to_time: 2021-08-11T11:36:38]`

Say you specify the timestamp `2021-08-11T19:16:21`. The closest backup is `2021-08-11T11:36:17Z 7.37KB [restore_to_time: 2021-08-11T11:36:38]`. PBM rounds down the timestamp to `2021-08-11T11:36:38` and deletes all slices that precede this time. As a result, your PITR time range is `2021-08-11T11:36:38 - 2021-08-12T09:00:25`.

**NOTE**: Percona Backup for MongoDB doesn’t delete the oplog slices that follow the most recent backup. This is done to ensure point in time recovery from that backup snapshot. For example, if the snapshot is `2021-07-20T07:05:23Z [restore_to_time: 2021-07-21T07:05:44]` and you specify the timestamp `2021-07-20T07:05:45`, Percona Backup for MongoDB deletes only slices that were made before `2021-07-20T07:05:23Z`.| -| `--force` | Forcibly deletes oplog slices without asking a user’s confirmation | +| `--force` | Forcibly deletes oplog slices without asking a user’s confirmation. Deprecated. Use the `-y`/`--yes` flag instead. | | `-o`, `--out=json` | Shows the output as either the plain text (default) or a JSON object. Supported values: `text`, `json`. | | `--yes` | Deletes backups without asking for user's confirmation | | `--dry-run` | Prints the list of oplog slices to be deleted without deleting them. You can use the flag to check what exactly will be deleted. Available starting with version 2.4.0. | +| `-w`, `--wait` | Wait for the deletion operation to complete. | ## pbm describe-backup 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. - From 6af883e347ff7d675029aad333e9d2867b744036 Mon Sep 17 00:00:00 2001 From: Anastasia Alexandrova Date: Tue, 27 Feb 2024 12:40:28 +0100 Subject: [PATCH 4/4] Update docs/reference/pbm-commands.md Co-authored-by: Sandra Romanchenko <53295797+sandraromanchenko@users.noreply.github.com> --- docs/reference/pbm-commands.md | 2 +- docs/usage/delete-backup.md | 59 ++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/docs/reference/pbm-commands.md b/docs/reference/pbm-commands.md index b3df255b..c4240da5 100644 --- a/docs/reference/pbm-commands.md +++ b/docs/reference/pbm-commands.md @@ -147,7 +147,7 @@ The command accepts the following flags: ## pbm delete-backup -Deletes the specified backup snapshot or backup snapshots of one or several types that are older than the specified time. The command deletes backups that are not running regardless of the remote backup storage being used. +Deletes the specified backup snapshot or all backup snapshots that are older than the specified time with the option to filter by specific type. The command deletes backups that are not running regardless of the remote backup storage being used. The following is the command syntax: diff --git a/docs/usage/delete-backup.md b/docs/usage/delete-backup.md index 3d37e25b..bac001cf 100644 --- a/docs/usage/delete-backup.md +++ b/docs/usage/delete-backup.md @@ -178,11 +178,64 @@ You can delete either a specified backup snapshot or all backup snapshots older 2021-04-21T02:16:33Z ``` -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. + +=== "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 + ``` + +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. ```{.bash data-prompt="$"} - $ pbm delete-backup --force 2021-04-20T13:45:59Z + $ pbm delete-backup --yes 2023-04-20T13:45:59Z ``` !!! admonition ""