Up
Previous Next

Sheriff CSM™

Back Up and Restore MongoDB

MongoDB is a cross-platform and open-source document-oriented database, a kind of NoSQL database. As a NoSQL database, MongoDB avoids the relational database’s table-based structure to adapt JSON-like documents that have dynamic schemas, which it calls BSON.

This makes data integration for certain types of applications faster and easier. MongoDB is built for scalability, high availability, and performance from a single server deployment to large and complex multi-site infrastructures.

Backing Up MongoDB

To back up MongoDB
  1. Connect to the Sheriff Console through SSH and use your credentials to log in.

    The Sheriff Setup menu displays.

  2. On the Sheriff Setup main menu, select Jailbreak System to gain command line access.

    Select Yes when prompted. You will be in the root directory.

  3. On the command line, type the following command:

    screen

    We recommend using the screen session so that you can keep the program running even after you log out.

  4. Back up the MongoDB database and create the dump directory:

    mongodump --host localhost
  5. Compress the file:

    tar cvfz sheriff-mongodb-`date +%s`.tgz dump

    Adding `date +%s` to the filename gives it a unique time stamp.

  6. Remove the dump directory:

    rm -rf ./dump
This procedure creates the sheriff-mongodb-<timestamp>.tgz file. Transfer the file to the target system. You can use either an SFTP client on Windows, such as WinSCP; or the SCP protocol on Linux.

Restoring MongoDB

Before following the procedure below, you should have deployed the SAME version of Sheriff CSM. You should have transferred the backup files to the target system and place them in the root directory.

To restore MongoDB
  1. Connect to the Sheriff Console through SSH and use your credentials to log in.

    The Sheriff Setup menu displays.

  2. On the Sheriff Setup main menu, select Jailbreak System to gain command line access.

    Select Yes when prompted. You will be in the root directory.

  3. On the command line, type the following command:

    screen

    We recommend using the screen session so that you can keep the program running even after you log out.

  4. Stop the following services so that they do not interfere with the process:

    /etc/init.d/monit stop
    /etc/init.d/vigilante-server stop
    /etc/init.d/vigilante-agent stop
    /etc/init.d/vigilante-framework stop
    /etc/init.d/sheriff-api stop
  5. Extract the file:

    tar xvzf sheriff-mongodb-<timestamp>.tgz
  6. Restore the backup file

    mongorestore --db inventory dump/inventory
  7. Remove the dump directory:

    rm -rf ./dump
  8. Restart all services for changes to apply:

    sheriff-reconfig -c -v -d
Topic revision: r6 - 31 Aug 2021, SheriffCyberSecurity
Copyright 2020 Sheriff Cyber Security, LLC. All rights reserved.