Using a granular restore operation for MongoDB

You can restore specific MongoDB databases or collections by using a granular restore operation. For a granular restore operation, first run a test restore job and then run the appropriate MongoDB commands.

Before you begin

If authentication is enabled, you must provide credentials for users so that they can correct permissions on the instance in the test restore operation.

About this task

The granular restore operation for MongoDB is based on a test mode restore job. When you run the test restore job on IBM Spectrum® Protect Plus, and the mongodump and mongorestore commands on the MongoDB server, you can access individual databases or collections from the recovery source.

Use this procedure to complete either of the following tasks:
  • Restore any number of databases by using the mongodump and mongorestore commands for the databases that you require.
  • Restore any number of collections by using the mongodump and mongorestore commands for the collections that you require.

Procedure

  1. In the navigation pane, click Manage Protection > Applications > MongoDB > Create job, and then select Restore to open the Restore wizard.
  2. On the Select source page, take the following actions:
    1. Click a source in the list to show the databases that are available for restore operations. You can also use the search function to search for available instances and toggle the displayed instances through the View filter.
    2. Click the add to restore list icon Add to restore list icon next to the database that you want to use as the source of the restore operation. You can select more than one database from the list.

      The selected sources are added to the restore list next to the database list. To remove an item from the list source, click the remove from restore list icon Remove from restore list icon next to the item.

    3. Click Next to continue.
  3. On the Restore method page, select Test, and click Next to continue with the test restore process.
  4. On the Set destination page, choose Restore to alternate instance, and select the target instance that you want to restore the data to.

    You cannot select the original instance is not selectable as you cannot overwrite the original data when you select Restore to alternate instance. Instances on different versions levels cannot be selected. Other instances on the same host as the original instance, cannot be selected either.

    Click Next to continue.
  5. Proceed through the restore wizard pages and select the required options.
  6. On the Review page, review your restore job settings.
    Attention: Review the selected options before you proceed to Submit because data will be overwritten when the Overwrite existing data application option is selected. You can cancel a restore job when it is in progress, but if the Overwrite existing data option is selected, data is overwritten even if you cancel the job.
  7. Log on to the MongoDB server to which the test restore job is directed.
  8. Run the MongoDB system command ps -ef | grep mongod to find the temporary recovery MongoDB instance location.
  9. Run the MongoDB mongodump command to create a dump file of any specific database or collection.
    Use the appropriate command. The first command is for a database and the second command is for a collection:
    mongodump --host <hostname> --port <port> --db <dbname> <dumpfolder>
    Or,
    mongodump --host <hostname> --port <port> --collection <collectionname> <dumpfolder>
  10. Run the mongorestore command to restore the dump file into any MongoDB instance. Choose either the original MongoDB instance that the backup was created for, or any alternative instance.
    Use the appropriate command. The first command is for a database and the second command is for a collection:
    mongorestore --host <hostname> --port <port> --db <dbname> <dumpfolder>\<dbname>
    Or,
    mongorestore --host <hostname> --port <port> --collection <collectionname> <dumpfolder>\<dbname>
  11. When the database or collection restore operation finishes, go to Jobs and Operations > Active Resources.
  12. Click Actions > Cancel Restore to end the granular restore procedure.