Skip to content
logo
Percona Backup for MongoDB
Delete backups
Initializing search
    percona/pbm-docs
    percona/pbm-docs
    • Home
      • How PBM works
      • Components
      • Supported MongoDB versions
      • Supported MongoDB deployments
      • Install
      • Set up and configure
      • Overview
      • Physical backups
      • Incremental physical backups
      • Logical backups
      • Selective backups
      • Point-in-Time Recovery
      • Start a backup
      • List backups
      • Restore a backup
      • View restore progress
      • Cancel a backup
      • Delete backups
        • Considerations
        • Behavior
          • Example
      • View backup logs
      • Replay oplog from arbitrary start time
      • Architecture
      • Authentication
        • Overview
        • Remote backup configuration examples
      • Schedule backups
      • Configure PBM remotely
      • Upgrade PBM
      • Troubleshoot PBM
      • Automate access to S3 buckets for PBM
      • Remove PBM
    • FAQ
      • PBM commands
        • Configuration file
        • Remote backup storage options
        • Point-in-time recovery options
        • Backup options
        • Restore options
      • Glossary
      • Release notes index
      • Percona Backup for MongoDB 2.0.4 (2023-02-21)
      • Percona Backup for MongoDB 2.0.3 (2023-01-11)
      • Percona Backup for MongoDB 2.0.2 (2022-10-27)
      • Percona Backup for MongoDB 2.0.1 (2022-10-12)
      • Percona Backup for MongoDB 2.0.0 (2022-09-21)
      • Percona Backup for MongoDB 1.8.1 (2022-07-12)
      • Percona Backup for MongoDB 1.8.0 (2022-06-09)
      • Percona Backup for MongoDB 1.7.0 (2022-04-18)
      • Percona Backup for MongoDB 1.6.1 (2021-11-04)
      • Percona Backup for MongoDB 1.6.0 (2021-08-16)
      • Percona Backup for MongoDB 1.5.0 (2021-05-10)
      • Percona Backup for MongoDB 1.4.1 (2021-01-28)
      • Percona Backup for MongoDB 1.4.0 (2020-12-24)
      • Percona Backup for MongoDB 1.3.4 (2020-11-19)
      • Percona Backup for MongoDB 1.3.3 (2020-11-04)
      • Percona Backup for MongoDB 1.3.2 (2020-10-14)
      • Percona Backup for MongoDB 1.3.1 (2020-09-03)
      • Percona Backup for MongoDB 1.3.0 (2020-08-26)
      • Percona Backup for MongoDB 1.2.1 (2020-07-27)
      • Percona Backup for MongoDB 1.2.0 (2020-05-13)
      • Percona Backup for MongoDB 1.1.3 (2020-04-14)
      • Percona Backup for MongoDB 1.1.1 (2020-01-31)
      • Percona Backup for MongoDB 1.1.0 (2020-01-16)
      • Percona Backup for MongoDB 1.0.0 (2019-09-19)
      • Percona Backup for MongoDB 0.5.0 (2019-06-17)
    • Submitting bug reports or feature requests
    • Copyright and Licensing
    • Trademark policy

    • Considerations
    • Behavior
      • Example

    Delete backups¶

    Use the pbm delete-backup command to delete either a specified backup snapshot or all backup snapshots older than the specified time.

    Note

    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 command.

    Starting with version 1.6.0, the command deletes only backup snapshots. Starting with version 2.0.0, you can also delete selective backups.

    To delete point-in-time recovery oplog slices, use the pbm delete-pitr command.

    Considerations¶

    To ensure oplog continuity for point-in-time restore, the pbm delete-backup command deletes any backup(s) but for the following ones:

    • 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 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:

    Backup snapshots:
      2022-10-05T14:13:50Z <logical> [restore_to_time: 2022-10-05T14:13:55Z]
      2022-10-06T14:52:42Z <logical> [restore_to_time: 2022-10-06T14:52:47Z]
      2022-10-07T14:57:17Z <logical> [restore_to_time: 2022-10-07T14:57:22Z]
    
    PITR <on>:
      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:

    • 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¶

    To delete a backup, specify the <backup_name> as an argument.

    pbm delete-backup 2021-12-20T13:45:59Z
    

    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.

    pbm delete-backup --force 2021-04-20T13:45:59Z
    

    To delete backups that were created before the specified time, pass the --older-than flag to the pbm delete-backup command. Specify the timestamp as an argument for pbm delete-backup in the following format:

    • %Y-%M-%DT%H:%M:%S (for example, 2021-04-20T13:13:20Z) or
    • %Y-%M-%D (2021-04-20).

    Example¶

    View backups:

    pbm list
    

    Output:

    Backup snapshots:
      2021-04-20T20:55:42Z
      2021-04-20T23:47:34Z
      2021-04-20T23:53:20Z
      2021-04-21T02:16:33Z
    

    Delete backups created before the specified timestamp

    pbm delete-backup -f --older-than 2021-04-21
    

    Output:

    Backup snapshots:
      2021-04-21T02:16:33Z
    

    Contact Us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.


    Last update: February 21, 2023
    Created: February 21, 2023
    Back to top
    Percona LLC and/or its affiliates, © 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.