Skip to content

Make a point-in-time restore

Preconditions

Run pbm status or pbm list commands to check that the full backup snapshot exists and there are oplog slices.

Before you start

  1. Disable point-in-time recovery. A restore and point-in-time recovery oplog slicing are incompatible operations and cannot be run simultaneously.

    $ pbm config --set pitr.enabled=false
    
  2. Stop the balancer and mongos nodes.

  3. Make sure no writes are made to the database during restore.

Procedure

Version added: 2.2.0

You can recover your database from a full or an incremental physical backup in the same automated fashion as from a logical one. Percona Backup for MongoDB restores the backup snapshot and automatically replays the oplog events on top of it up to the specified time, guaranteeing data consistency. This helps you prevent data loss during a disaster and gives you the same user experience when managing backups and restores.

To restore a database from a physical backup, specify the time for the pbm restore command:

$ pbm restore --time <timestamp> -w

Percona Backup for MongoDB recognizes if it is a full or an incremental backup and restores the database from it up to the specified time.

Note

For PBM versions earlier then 2.3.0, the command for the point-in-time recovery is the following:

$ pbm restore --base-snapshot=<backup_name> --time <timestamp> -w 

The --base-snapshot flag is required. Otherwise, PBM will look for a logical backup even if there is none or there is a more recent physical backup.

Post-restore steps

After the point-in-time recovery is complete, perform these post-restore steps:
1. Restart all mongod nodes.

  1. Restart all pbm-agents.

  2. Resync the backup list with the storage:

    $ pbm config --force-resync
    
  3. Start the balancer and start mongos nodes.

  4. Make a fresh backup to serve as the new base for future restores.

  5. Enable point-in-time routine to resume saving oplog slices.

Percona Backup for MongoDB version 2.1.0 and earlier

For Percona Backup for MongoDB version 2.1.0 and earlier, point-in-time recovery consists of the following steps:

  • Restore from the physical backup snapshot.
  • Manual replay of oplog events on top of this snapshot up to a specific timestamp.

For how to replay oplog events on top of a backup, see Oplog replay for physical backups.

Implementation specifics

  1. Due to the physical restore logic and flow, PBM replays oplog events on the primary node of every shard when Percona Server for MongoDB is shut down. After the database start, the remaining nodes receive the data during the initial sync.
  2. When doing point-in-time recovery for deployments with sharded collections, PBM only writes data to existing ones and doesn’t support creating new collections. Therefore, whenever you create a new sharded collection, make a new backup for it to be included there.

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: November 1, 2024
Created: November 1, 2024