Delete backup older than x days

Hello,

Any suggestions to delete backups older than X days. I used below command but didn’t work ( it didn’t delete any).

[mongod@ip-xxxx pbm]$ pbm delete-backup -f --older-than $(date -d ‘-5 days’ +%Y-%m-%d);
Waiting for delete to be done …[done]
Backup snapshots:
2022-10-22T01:02:04Z [complete: 2022-10-22T23:00:52Z]
2022-11-05T01:02:04Z [complete: 2022-11-05T17:24:38Z]
2022-11-12T01:02:04Z [complete: 2022-11-12T23:25:56Z]

PITR :
2022-10-22T23:00:53Z - 2022-10-23T18:00:13Z
2022-11-05T17:24:39Z - 2022-11-06T18:00:11Z
2022-11-12T23:25:57Z - 2022-11-13T18:00:08Z

is there a automation script/command to delete the older backups by keeping 2 set of recent backups.

1 Like