Performing a Full Backup of a Standalone MongoDB Deployment

Use the file system agent to back up and restore the MongoDB dumps of the databases.

MongoDB application provides the following native utilities to create and restore dumps:

  • mongodump - which produces a binary file dump based backup of the database

  • mongorestore - which takes the binary file dump based backup as input to restore the database, automatically creating indexes as required

Commvault software provides a simplified backup and recovery solution for MongoDB data in your enterprise using the File System Agent. File system snapshots taken using IntelliSnap backups can also be used to secure MongoDB data.

Note

Commvault does not back up mount points from subdirectories that are under the dbPath. To protect the mount point on the subdirectory that is under the dbPath, create a symbolic link pointing to the mount point.

Back Up Using File System Agent

You need to install the File System Agent on the client computer before configuring backup and restores.

Perform a Backup

  1. From the CommCell Browser, navigate to <Client> | File System | defaultBackupSet.

  2. Right-click the default subclient, and then click Properties.

  3. On the Subclient Properties of default dialog box, perform the following:

    • Click the Pre/Post Process tab.

    • Click Browse to select the script file containing the mongodump command in the PreScan process box, and then click OK.

      On Windows, sample mongoBackup.bat script file:

      mongodump --db test --out E:\mongoduTemp > E:\mongodScripts\backupOut

      On UNIX, sample mongoBackup.sh script file:

      mongodump --db test --out /root/mongoduTemp >>/root/mongodScripts/backupOut 2>>/root/mongodScripts/backupOut
    • Click the Content tab.

    • Click Browse to specify the output dump directory as content for the subclient, and then click OK.

      For example:

      On Windows: E:\mongoduTemp

      On UNIX: /root/mongoduTemp

      Note

      Make sure that there is enough space on the staging area, E:\mongoduTemp or /root/mongoduTemp, in this example. You can configure a script to run as part of the post backupprocess for cleaning up the staging area after the backup job is complete.
      For example, on Windows:RD /s /q E:\mongoduTemp
      On UNIX:rm -rf /root/mongoduTemp/*

    • Click the Storage Device tab.

    • Select a storage policy from the Storage Policy list.

    • Click OK to close the Subclient Properties of default dialog box.

  4. Right-click the default subclient, and then click Backup.

  5. On the Backup Options for Subclient:default dialog box, click Full, and then click Immediate.

  6. Click OK to start the backup job.

Restore Data

  1. From the CommCell Browser, navigate to Client Computers | <Client> | File System | defaultBackupSet.

  2. Right-click the default subclient, and then click Browse and Restore.

  3. On the Browse and Restore Options dialog box, click View Content.

  4. Select the entire data directory, and then click Recover All Selected.

  5. On the Restore Options for All Selected Items dialog box, click Advanced.

  6. On the Advanced Restore Options dialog box, perform the following:

    • Click the Pre/Post tab.

    • Click Browse to select the script file containing the mongorestore command with the target dump directory in the Post Recovery Command box.

    • Click OK.

    On Windows, sample mongoRestore.bat script file:

    mongorestore E:\mongoduTemp > E:\mongodScripts\restoreOut

    On UNIX, sample mongoRestore.sh script file:

    mongorestore /root/mongoduTemp >>/root/mongodScripts/restoreOut 2>>/root/mongodScripts/restoreOut
  7. Click OK to start the restore job.

IntelliSnap Backup

IntelliSnap backup enables you to create a point-in-time snapshot of the data to be used for various backups.

Perform a Backup

  1. From the CommCell Browser, navigate to Client Computers | <Client>.

  2. Right-click the client, and then click Properties.

  3. On the Client Computer Properties for <Client> dialog box, click Advanced.

  4. On the Advanced Client Properties dialog box, select the Enable IntelliSnap check box.

  5. Click OK to close the Advanced Client Properties dialog box.

  6. Navigate to<*Client*> | File System | defaultBackupSet.

  7. Right-click the default subclient, and then click Properties.

  8. On the Subclient Properties of default dialog box, perform the following:

    • Click the IntelliSnap Operations tab, and then select the IntelliSnap check box.

    • Select a snap engine from the Available Snap Engine list.

    • From the Use Proxy list, select the MediaAgent where IntelliSnap and backup copy operations will be performed.

      Note

      When performing IntelliSnap backup using proxy, make sure that the operating system of the proxy server is either same or higher version than the client computer.

    • Select the Use Separate Proxy for Backup Copy check box if you want to perform backup copy operations in a different MediaAgent.

      Select the MediaAgent from the Proxy list.

    • Click the Content tab, and then click Browse to specify the data directory as content for the subclient.

      For example, on Windows: F:\mongodb\data

      On UNIX: /mnt/iscsi/mongodbpath

      To prevent write locks blocking the server during the backup, keep only the output dump directory as the subclient content.

    • Click the Pre/Post Process tab.

      Click Browse to select the script to quiesce the database in the PreSnap Process box.

      Click Browse to select the script to unquiesce the database in the PostSnap Process box.

      • To get a backup of consistent state if journaling is not enabled on instances or if the journal is on a separate volume, all the writes must be flushed to the disk and the database must be locked to prevent writes during backups.

      • Lock database: To flush writes to disk and to lock the database (to prevent further writes), add the following script as a pre-snap process:

        For example,

        On Windows, mongoQuiesce.bat, the contents of which are:

        mongo <db_name> quiesce.js > E:\mongodScripts\quiesceOut

        On UNIX, mongoQuiesce.sh, the contents of which are:

        mongo <db_name> quiesce.js > /root/mongodScripts/quiesceOut

        where quiesce.js contains:

        db.fsyncLock();

        Note

        The database cannot be locked with db.fsyncLock() while profiling is enabled. You must disable profiling before locking the database with db.fsyncLock(). Disable profiling using db.setProfilingLevel() as follows in the mongo shell:db.setProfilingLevel(0))

      • Unlock database: To unlock the database after the snapshot has completed, add the following script as a PostSnap Process:

        For example:

        On Windows, mongoUnquiesce.bat, the contents of which are:

        mongo <db_name> unquiesce.js > E:\mongodScripts\unquiesceOut

        On UNIX, mongoUnquiesce.sh, the contents of which are:

        mongo <db_name> unquiesce.js > /root/mongodScripts/unquiesceOut

        where unquiesce.js contains:

        db.fsyncUnlock();

        Note

        Changes in version 2.0: MongoDB 2.0 added db.fsyncLock() and db.fsyncUnlock() helpers to the mongo shell. For prior versions, use the fsync command with the lock option, as follows:db.runCommand( { fsync: 1, lock: true } );``db.runCommand( { fsync: 1, lock: false } );

      • Click the Storage Device tab, and then select a storage policy from the Storage Policy list.

      • Click OK to close the Subclient Properties of default dialog box.

  9. Right-click the default subclient, and then click Backup.

  10. On the Backup Options for Subclient:default dialog box, click Full, and then click Immediate.

  11. Click OK to start the backup job.

Restore Data

  1. From the CommCell Browser, navigate to Client Computers | <Client> | File System.

  2. Right-click the entity that contains the snapshots you want to restore, and then click All Tasks | Browse and Restore.

  3. On the Browse and Restore Options dialog box, click View Content.

  4. Select the entire data directory to be restored, and then click Recover All Selected.

  5. On the Restore Options for All Selected Items dialog box, click Advanced.

  6. On the Advanced Restore Options dialog box, perform the following:

    • Click the Copy Precedence tab, and then select the Restore from Copy Precedence check box.

    • Type the copy precedence number for the backup copy in the Copy Precedence box.

    • Click OK.

  7. Click OK to close the Restore Options for All Selected Items dialog box and start the restore job.

  8. In the event of unclean database shutdown, run these commands as required.

    mongod --repair

    or

    mongod --repairpath <path>

    where <path> is the root directory containing MongoDB data files.

Schedule a Backup

  1. From the CommCell Browser, navigate to Client Computers | <Client> | File System | defaultBackupSet.

  2. Right click the default subclient, and then click Backup.

  3. On the Backup Options for Subclient: default dialog box, perform the following:

    • Click Schedule.

    • Click Configure.

    • Select the appropriate scheduling options. For example:

      • Click Weekly.

      • Check the days you want the run the restore job.

      • Change the Start Time to 9:00 PM

      • Click OK to close the Schedule Details dialog

  4. Click OK.

    The backup job will execute as per the schedule.

See Scheduling for a comprehensive information on scheduling jobs.

Loading...