# Unable to delete PBM backups (both PITR and full backups)

**URL:** <https://forums.percona.com/t/unable-to-delete-pbm-backups-both-pitr-and-full-backups/19788>\
**Category:** Percona Backup for MongoDB\
**Tags:** percona, mongodb, pbm\
**Created:** [January 26, 2023, 2:34pm UTC](https://forums.percona.com/t/unable-to-delete-pbm-backups-both-pitr-and-full-backups/19788 "2023-01-26T14:34:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirangelli](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kirangelli](https://forums.percona.com/u/kirangelli)\
**Post date:** [January 26, 2023, 2:34pm UTC](https://forums.percona.com/t/unable-to-delete-pbm-backups-both-pitr-and-full-backups/19788/1 "2023-01-26T14:34:52Z")

</div>

Hi Team,

We are currently using PBM version 2.0

Issue#1 (without PITR)  
I am unable to delete PBM backups that are older than ‘X’ number of days.

Command I’m using for deleting the backups older than 5 days.  
pbm delete-backup -f --older-than $(date -d ‘-5 days’ +%Y-%m-%d);

How can we setup backup retention policy in PBM?  
Can we setup a cron to delete the backups in parallel with the backup schedule job?

Issue#2  
For a replicaset on which PITR is enabled, we are unable to delete the PITR chunks manually.

Example command that doesn’t work  
pbm delete-pitr --older-than=“2022-09-24T18:49:36Z” # will delete [2022-09-17T17:39:12Z - 2022-09-18T17:44:51Z]

Please help me on this.

I see an open JIRA for ability to delete older backups/pitr chunks. Any Idea when will this JIRA gets resolved?  
[https://jira.percona.com/browse/PBM-850](https://jira.percona.com/browse/PBM-850)

Thanks  
Kiran

---

<div class="post-metadata">

**Author:** ![Dmytro\_Zghoba](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dmytro_zghoba/32/4721_2.png) [@Dmytro\_Zghoba](https://forums.percona.com/u/Dmytro_Zghoba)\
**Post date:** [February 8, 2023, 10:06am UTC](https://forums.percona.com/t/unable-to-delete-pbm-backups-both-pitr-and-full-backups/19788/2 "2023-02-08T10:06:36Z")

</div>

Hey, @kirangelli

Sorry for the delay. We discussed your case and required changes to PBM logic. We will provide solution to simply/easy maintain retention policy in the next release.

You can track the progress here [[PBM-850] Add ability to delete older backups - Percona JIRA](https://jira.percona.com/browse/PBM-850)

For now, PBM does not allow to delete old backups if they are the base snapshot for Point-in-Time restore. You have to delete oplog ranges that covers these snapshots first. Valid ranges for deletion are before/older than the latest/recent full backup.

---

<div class="post-metadata">

**Author:** ![kirangelli](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kirangelli](https://forums.percona.com/u/kirangelli)\
**Post date:** [February 8, 2023, 1:15pm UTC](https://forums.percona.com/t/unable-to-delete-pbm-backups-both-pitr-and-full-backups/19788/3 "2023-02-08T13:15:45Z")

</div>

Hey @Dmytro_Zghoba

Thank you for your response.

---

<div class="post-metadata">

**Author:** ![kirangelli](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kirangelli](https://forums.percona.com/u/kirangelli)\
**Post date:** [June 2, 2023, 4:48am UTC](https://forums.percona.com/t/unable-to-delete-pbm-backups-both-pitr-and-full-backups/19788/4 "2023-06-02T04:48:15Z")

</div>

Hey @Dmytro_Zghoba

We have upgraded our PBM to the latest version 2.1.0 with PITR enabled.  
Storage location: AWS S3 bucket.

However, when I tried to delete the backups using the below command.  
pbm cleanup --older-than=“2023-05-18T15:00:00”, it is throwing the below error.

Error:  
2023-05-31T10:12:37Z E [XXXPROD/xxx:27017] [cleanup] delete chunk file “pbmPitr/xxxprod/20230513/20230513080806-2.20230513081806-2.oplog.s2”: delete ‘pbm-mongo-prod/pbmPitr/XXX/20230513/20230513080806-2.20230513081806-2.oplog.s2’ file from **S3: AccessDenied: Access Denied**  
**status code: 403** , request id: 7ADR2VEW0MVF3N6J

Do we need to make any changes to the configuration? or grant permissions to specifc user at the S3 bucket level?  
Please advice.

Thanks  
Kiran

---

<div class="post-metadata">

**Author:** ![Dmytro\_Zghoba](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dmytro_zghoba/32/4721_2.png) [@Dmytro\_Zghoba](https://forums.percona.com/u/Dmytro_Zghoba)\
**Post date:** [June 2, 2023, 6:00am UTC](https://forums.percona.com/t/unable-to-delete-pbm-backups-both-pitr-and-full-backups/19788/5 "2023-06-02T06:00:32Z")

</div>

hi @kirangelli,

I see S3-side error. Please double-check permissions.
