Backup planning

Hello there,

I installed and configured Percona Backup for MongoDB, I did some backup and restore tests with physical, incremental e logical type of backup, including the PITR incremental to true.

I would like to know how can I plan a backup strategy including the retention, an example as I would need the following:

  • full backup every week on sunday, with 35 days of retention
  • incremental backup from monday to saturday, with 32 days of retention
  • PITR incremental backup every 15 minutes, with 24 hours of retention
  • full month backup, with 13 months of retention
  • full year backup, with 7 years of retention

Thank you in advance to all will reply.

Hello Enrico,

We usually configure backup generation and cleanup using cron jobs.

You can add as many entries as necessary in your crontab configuration, for instance:

full backup every week on sunday: 
0 0 * * SUN percona . /etc/sysconfig/pbm-cron; /usr/bin/pbm backup --type incremental --base  >> /var/log/percona/pbm_bkp.log 2>&1

The line above runs backup every Sunday at 00:00

with 35 days of retention >> This can be done with pbm delete-backup command:

0 6 * * * percona . /etc/sysconfig/pbm-cron; /usr/bin/pbm delete-backup -f --older-than $(date -d '-35 day' +\%Y-\%m-\%d) >> /var/log/percona/pbm_remove_old_backups.log 2>&1

Incremental backups can be scheduled in a similar way, but you need to remove the --base flag

PITR oplog slices can be deleted with pbm delete-pitr command:

https://docs.percona.com/percona-backup-mongodb/reference/pbm-commands.html#pbm-delete-pitr

As to the frequency of oplog slice generation, I believe you need to set this parameter in your pbm configuration: https://docs.percona.com/percona-backup-mongodb/reference/pitr-options.html#pitroplogspanmin

We advise you to always test your backup restore process considering all disaster recovery scenarios.
Please let us know if our advise works for you.

Cheers!

Hi arlindo.neto,

Thanks for the detailed explanation of cron and pbm abilities.

But You ignored the last part of the question:

  • full month backup, with 13 months of retention
  • full year backup, with 7 years of retention

Do you have any recommendations here?
Or the only recommendation would be to use custom scripts which will just copy the backups from folder to folder? But then pbm will not see them.

Cheers!

A feature to add some kind of tag to backups (when created and potentially afterwards) and filtering backups by that tag on cleanups would be nice.

E.g. pbm backup --tag=monthly on backup and then pbm cleanup --older-than=2024-01-05 --tag=monthly (PITR likely does not make sense to tag and should be cleaned up with all cleanups) (Running cleanups / delete-backup without --tag should clean up everything, possibly with a warning / confirmation if it matches tagged backups)

(multiple tags and/or key/value might make sense as well, but filtering / matching rules gets more complicated)

Other commands that would make sense:
pbm tag
pbm untag

This should give a decent way to retain a selection of backup snapshots for longer…