Skip to content
logo
Percona Monitoring and Management
Restore a MongoDB backup
Initializing search
    percona/pmm-doc
    percona/pmm-doc
    • Welcome
        • Network
        • Docker
        • Podman
        • Helm
        • Virtual Appliance
        • AWS Marketplace
        • Easy-install script
        • MySQL
        • MongoDB
        • PostgreSQL
        • ProxySQL
        • Amazon RDS
        • Microsoft Azure
        • Google Cloud Platform
        • Linux
        • External Services
        • HAProxy
        • Remote instances
      • User Interface
      • Percona Alerting
        • Prepare a storage location
          • MongoDB backup prerequisites
          • Create MongoDB on-demand and scheduled backups
          • Create MongoDB PITR backups
          • Restore a MongoDB backup
            • Restore to a new cluster manually
              • Restoring from a sharded cluster
          • MongoDB Backup and Restore support matrix
          • MySQL backup prerequisites
          • Create a MySQL backup
          • Restore a MySQL backup
        • Edit a scheduled backup
        • Delete a backup
        • Configure access control
        • Labels for access control
        • Create access roles
        • Manage access roles
        • Assign roles to users
        • Use Case
      • Query Analytics
      • Working with Advisors
      • Configure
      • Manage users
      • Upgrade
      • Secure
      • Optimize
      • Annotate
      • Share dashboards and panels
      • Extend Metrics
      • Resolve issues
        • Check Percona Portal account information
      • Architecture
      • UI components
      • PMM components and versions
      • Data handling in PMM
      • Develop Advisor checks
      • PMM Inventory
        • Manage dashboards
            • Advanced Data Exploration
            • VictoriaMetrics
            • VictoriaMetrics Agents Overview
            • Environment Summary
            • Kubernetes Pods Status
            • Kubernetes Volumes
          • DBaas
            • Disk Details
            • Network Details
            • Memory Details
            • Node Temperature Details
            • Nodes Compare
            • Nodes Overview
            • Node Summary
            • NUMA Details
            • Processes Details
            • Prometheus Exporters Overview
            • MySQL Command/Handler Counters Compare
            • MySQL InnoDB Compression Details
            • MySQL InnoDB Details
            • MySQL MyISAM/Aria Details
            • MySQL MyRocks Details
            • MySQL Instance Summary
            • MySQL Instances Compare
            • MySQL Instances Overview
            • MySQL Wait Event Analyses Details
            • MySQL Performance Schema Details
            • MySQL Query Response Time Details
            • MySQL Replication Summary
            • MySQL Group Replication Summary
            • MySQL Table Details
            • MySQL User Details
            • MySQL TokuDB Details
            • Experimental MongoDB Collection Details
            • Experimental MongoDB Oplog Details
            • MongoDB Cluster Summary
            • MongoDB Instance Summary
            • MongoDB Instances Overview
            • MongoDB Instances Compare
            • MongoDB ReplSet Summary
            • MongoDB InMemory Details
            • MongoDB MMAPv1 Details
            • MongoDB WiredTiger Details
            • PostgreSQL Instance Summary
            • PostgreSQL Instances Compare
            • Experimental PostgreSQL Vacuum Monitoring
          • ProxySQL Dashboards
            • PXC/Galera Cluster Summary
            • Experimental PXC/Galera Cluster Summary
            • PXC/Galera Nodes Compare
            • HAProxy Instance Summary
        • pmm-admin - PMM Administration Tool
        • pmm-agent - PMM Client agent
      • API
      • VictoriaMetrics
      • ClickHouse
      • PostgreSQL
      • Glossary
      • Introduction
      • DBaaS architecture
        • Setting up DBaaS
        • Create a Kubernetes Cluster
        • Deleting Kubernetes clusters
        • Activating DBaaS
        • Add a Kubernetes cluster automatically
        • Add a Kubernetes cluster manually
        • Manage allowed component versions
          • OLM installation
          • Operators installation
        • Add a DB Cluster
        • Manage a DB Cluster
        • Delete a DB Cluster
        • Create a database cluster from a template
      • Backup and restore
    • FAQ
      • PMM 2.39.0
      • PMM 2.38.1
      • PMM 2.38.0
      • PMM 2.37.1
      • PMM 2.37.0
      • PMM 2.36.0
      • PMM 2.35.0
      • PMM 2.34.0
      • PMM 2.33.0
      • PMM 2.32.0
      • PMM 2.31.0
      • PMM 2.30.0
      • PMM 2.29.1
      • PMM 2.29.0
      • PMM 2.28.0
      • PMM 2.27.0
      • PMM 2.26.0
      • PMM 2.25.0
      • PMM 2.24.0
      • PMM 2.23.0
      • PMM 2.22.0
      • PMM 2.21.0
      • PMM 2.20.0
      • PMM 2.19.0
      • PMM 2.18.0
      • PMM 2.17.0
      • PMM 2.16.0
      • PMM 2.15.1
      • PMM 2.15.0
      • PMM 2.14.0
      • PMM 2.13.0
      • PMM 2.12.0
      • PMM 2.11.1
      • PMM 2.11.0
      • PMM 2.10.1
      • PMM 2.10.0
      • PMM 2.9.1
      • PMM 2.9.0
      • PMM 2.8.0
      • PMM 2.7.0
      • PMM 2.6.1
      • PMM 2.6.0
      • PMM 2.5.0
      • PMM 2.4.0
      • PMM 2.3.0
      • PMM 2.2.2
      • PMM 2.2.1
      • PMM 2.2.0
      • PMM 2.1.0
      • PMM 2.0.1
      • PMM 2.0.0
      • Copyright and licensing information
      • Trademark policy

    • Restore to a new cluster manually
      • Restoring from a sharded cluster

    Restore a MongoDB backup¶

    MongoDB backups can only be restored to the same service they were created from.

    To restore a backup:

    1. Go to Backup > All backups and find the backup that you want to restore.
    2. Click the arrow in the Actions column to check all the information for the backup, then click Restore from backup. This opens the Restore from backup dialog, with the Same service option automatically preselected. This is because, currently, MongoDB backups can only be restored to a service with identical properties.
    3. If you are restoring a PITR backup, select the point for the date and time that you want to restore the database to.
    4. Click Restore then go to the Restores tab to check the status of the restored backup.

    Important

    During restoring, PMM disables all the scheduled backup tasks for the current service. Remember to re-enable them manually after the restore.

    Restore to a new cluster manually¶

    1. Install MongoDB and Percona Backup for MongoDB. Pay attention to the versions. To minimize potential incompatibility, use the same versions that were used for taking backups. For instructions, see the PBM install documentation.
    2. Configure your environment:

      • to restore to a new environment with the same replica set name, make sure that the replica set name in your new destination cluster use the same name as that in the cluster that was backed up.
        For more information, see Restoring a backup into a new-environment in the PBM documentation.
      • to restore logical backups to a new environment that has a different replica set name, configure the name mapping between the source and target environments.
        For the new environment, you can either set the PBM_REPLSET_REMAPPING environment variable for pbm CLI, or use the --replset-remapping flag for PBM commands.

        The mapping format is <rsTarget>=<rsSource>.

        For example:

        $ export PBM_REPLSET_REMAPPING="targetRS=sourceRS"

        OR

        $ pbm restore <timestamp> --replset-remapping="targetRS=sourceRS"

        For more information, see Restoring into a replica set with a different name in the PBM documentation.

    3. Make sure that Percona Backup for MongoDB configuration in the new environment points to the remote storage defined for the original environment, including the authentication credentials for object stores.

      The easiest way to configure it is to create a config file, called, for example, pbm_config.yaml.

      For this, you can either copy the config from the source host or create a new one.

      To redirect the config output from the existing environment, use:

        pbm config >> pbm_config.yaml
      
      then copy the resulting file to the new environment.

      Here’s an example of config file content for AWS S3-compatible storage:

      storage:
        type: s3
        s3:
          region: us-west-2
          bucket: pbm-test-bucket
          prefix: backup_name_from_pmm
          credentials:
            access-key-id: <your-access-key-id-here>
            secret-access-key: <your-secret-key-here> 
      
      The prefix name is the artifact name that appears in the Backup name column, under Backup > All Backups page:

      !

      To implement the config, use the following command:

      pbm config --file pbm_config.yaml
      

      For more information, see Restoring a backup into a new-environment in the PBM documentation.

    4. Run pbm list to check if pbm is ready to perform the restore procedure.

    5. Once all the backups made from the original environment are available, run the restore command:

      • For snapshot backups:

        a) run the following command:

        pbm list
          Backup snapshots: 2022-11-23T19:40:06Z [restore_to_time: 2021-01-13T15:53:40Z]
        
        b) provide the timestamp of the backup to the pbm command:

        pbm restore 2022-11-23T19:40:06Z

        For more information, see Restore a backup topic in the PBM documentation.

      • For PITR backups:

        a) run the following command:

          pbm list
          Backup snapshots:
            2022-11-23T19:40:06Z <logical> [restore_to_time: 2022-11-23T19:40:25Z]
            2022-11-23T19:45:07Z <logical> [restore_to_time: 2022-11-23T19:45:22Z]
          PITR <on>:
            2022-11-23T19:40:26Z - 2022-11-23T19:45:22Z
        
        b) provide the timestamp from one of the PITR ranges to the pbm command:

        pbm restore --time="2022-11-23T19:40:26

      For more information, see the Point-in-time Recovery topic in the PBM documentation.

    6. Check the progress of the restore operation, using one of the commands below:

      • For logical restores: pbm describe-restore <restore_name>

      • For physical restores: pbm describe-restore --config=/path/to/pbm_config.yaml <restore_name>

      Required arguments:

      • PBM generates the <restore_name> information after you start the restoring.
      • The pbm_config.yaml file required for physical restores is the PBM config file that you provided for step 3.

    Important

    Make sure not to run pbm backup from the new environment while the Percona Backup for MongoDB config is pointing to the remote storage location of the original environment.

    Restoring from a sharded cluster¶

    Sharded cluster backups are supported starting with PMM 2.38 and PMM handles the backup process end-to-end. However, restoring such artifacts is currently possible only via the CLI, using Percona Backup for MongoDB.

    For information on restoring sharded backups, check the PBM documentation

    Contact us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.


    Last update: 2023-09-22
    Percona LLC, © 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better. Read more about Percona Cookie Policy.