Back Up and Restore MongoDB

Applies to Product: USM Appliance™ LevelBlue OSSIM®

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 LevelBlue Console through SSH and use your credentials to log in.

    The LevelBlue Setup menu displays.

  2. On the LevelBlue 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 alienvault-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 alienvault-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 USM Appliance. 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 LevelBlue Console through SSH and use your credentials to log in.

    The LevelBlue Setup menu displays.

  2. On the LevelBlue 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/ossim-server stop

    /etc/init.d/ossim-agent stop

    /etc/init.d/ossim-framework stop

    /etc/init.d/alienvault-api stop

  5. Extract the file:

    tar xvzf alienvault-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:

    alienvault-reconfig -c -v -d