Planning Your Data Protection

SHIELD can perform MongoDB backups in a few different ways, depending on your network throughput, access control, and personal preferences.

Local Agent

The simplest method is to run the SHIELD agent on the same box as the mongod process, and use the local MongoDB socket to connect to the database server.

If you want to protect more than one database host, you can install the agent on each. They will all then register with the SHIELD instance, with different identities, and you can configure backup jobs for each of them.

Remote Agent

You can also run the SHIELD agent somewhere else, and configure your backup jobs to connect to the MongoDB host(s) over TCP, using either their public IPs, or (if you have configured them) internal Linode IPs.

This can be useful if you'd rather not load additional software on your database host(s). You can also reuse the external agent to protect multiple MongoDB instances, since your backup jobs will specify the IP address of each.

System Prerequisites

SHIELD uses native tooling to perform backup and restore operations against MongoDB. For this to work, you will need to install the following tools, matched to the version of MongoDB you are running:

  1. mongodump for dumping objects from one or more databases.
  2. mongorestore for replaying snapshots, upon restore.

Configuring Backup Jobs

With MongoDB, you can limit which databases you protect. For most use cases, you'll want to backup all of the databases, but you can limit your export to a single database.

It's entirely up to you.

Authentication

Four parameters govern the authentication to your MongoDB server: MongoDB Host, MongoDB Username, MongoDB Password, and Authentication Database.

By default, the plugin will assume that MongoDB is accessible on loopback on the default port (http://127.0.0.1:27017), without requiring authentication.

If you enable authentication by supplying a MongoDB Username and MongoDB Password, the plugin will attempt to authenticate against the default database. If your user exists in a different database, you'll need to specify as much via the Authentication Database parameter.

Backing up All Databases

The default configuration of the MongoDB backup plugin is to protect all databases found.

You dont' have to do anything — just make sure to leave the Backup Database parameter blank (its default value)!

Backing up a Single Database

If you only want to back up a single database, specify the name of that database in the Backup Database parameter when you configure your data system.

Note: this parameter has no bearing on restores; SHIELD will restore all databases found in the snapshot archive, regardless of what you set for Backup Database.

Restoring MongoDB from a Snapshot

MongoDB SHIELD snapshots consist of mongodump output for the given database(s) in-scope when the snapshot was taken. These are replayed during restore operations by the mongorestore utility.

It is worth noting that mongorestore will recreate whatever objects are in the snapshot! If you run a full backup, including all databases, and then reconfigure the data system to specify a single database, the archive created before the reconfiguration will still have data from all databases in it.

Configuration Reference

This section details all available configuration parameters for the MongoDB data protection plugin.

MongoDB Host
The hostname or IP address (and port) of your MongoDB server.
MongoDB Username
Username to authenticate to MongoDB as.
MongoDB Password
Password to authenticate to MongoDB as.
Backup Database
Limit the scope of the backup to the named database. By default, all databases are backed up.
Authentication Database
The database to authenticate against.
Mongo Options
You can tune `mongodump` and `mongorestore` by specifying additional options and command-line arguments.
mongorestore Options
You can tune `mongorestore` (only) by specifying additional options and command-line arguments.
mongodump Options
You can tune `mongodump` (only) by specifying additional options and command-line arguments.