Skip to content

How Percona Backup for MongoDB works

Even in a highly-available architecture, such as with MongoDB replication, backups are still required even though losing one server is not fatal. Whether for a complete or partial data disaster, you can use PBM (Percona Backup for MongoDB) to go back in time to the best available backup snapshot.

Percona Backup for MongoDB is a command line interface. It provides the set of commands to manage backup and restore operations in your database.

Usage example

Let’s have a look at how Percona Backup for MongoDB works.

With Percona Backup for MongoDB up and running in your environment, make a backup:

$ pbm backup

To save all events that occurred to the data between the backups, enable saving oplog slices:

$ pbm config --set pitr.enabled=true

Now, imagine that your web application’s update was released on February 7 at 03:00 UTC. By 15:23 UTC, someone realizes that this update has a bug that is wiping the historical data of any user who logged in. To remediate this negative impact on data, it’s time to roll back up to the time of the application’s update - up to February 7, 03:00 UTC.

$ pbm list

The output lists the valid time ranges for the restore. The desired time (February 7, 03:00 UTC) falls within the 2021-02-03T08:08:36Z-2021-02-09T12:20:23Z range, so let’s restore the database up to that time.

Since the restore and saving oplog slices are exclusive operations and cannot run together, let’s stop the oplog slicing first:

$ pbm config --set pitr.enabled=false

Now, let’s restore the database:

$ pbm restore --time 2021-02-07T02:59:59

To be on the safe side, it is a good practice to make a fresh backup after the restore is complete.

$ pbm backup

This backup refreshes the timeline and serves as the base for saving oplog slices. To re-enable this process, run:

$ pbm config --set pitr.enabled=true

Next steps

Ready to try it out?

Quickstart

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services.


Last update: March 26, 2024
Created: March 26, 2024