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