Navigation

Query a Backup Snapshot

Ops Manager provides queryable backups. This functionality allows you to query specific backup snapshot. You can use the queryable backups to:

  • Restore a subset of data within the MongoDB deployment.
  • Compare previous versions of data against the current data.
  • Identify the best point in time to restore a system by comparing data from multiple snapshots.

Considerations

Read-Only Instance

Ops Manager provisions these queryable snapshots as read-only MongoDB instances. Specifically, Ops Manager spins up a mongod with data from the selected snapshot store.

Important

By default, these instances are available for up to 24 hours. You can configure the duration using Expiration (Hours). For other queryable backup settings, see Queryable Snapshot Configuration.

Query Restrictions on the Queryable Snapshots

  • You cannot run map-reduce operations.
  • You cannot run queries that requires disk usage, such as running aggregation with the allowDiskUse option to perfrom large sort operations.

Connection Methods

Connections to these instances are over TLS/SSL and require a X.509 authentication. Ops Manager provides:

  • An executable that creates a tunnel which handles the connection, including the client TLS/SSL and the X.509 authentication.

    Requests are routed through the tunnel. The tunnel ensures the request is speaking to the correct mongod instance.

  • X.509 certificates if you want to handle the connection details manually, including the TLS/SSL and the X.509 authentication.

    Requests come in through the web server, which acts as a proxy to the mongod.

Prerequisites

MongoDB Version

  • Queryable backups are available for MongoDB 3.2 or later replica sets or MongoDB 3.2 or later sharded clusters with replica set config servers (CSRS).
  • Backup daemons require MongoDB 3.4.2 Enterprise or later for queryable backups.

PEM file

For the queryable backup host, you must specify the location of the PEM file using the Proxy Server PEM File setting. If you have not already set up the queryable backup settings:

  1. Click on Admin on the upper-right hand corner. From the Admin screen, click on General > Ops Manager Config > Backup.

  2. Scroll to the Queryable Snapshot Configuration and specify the Proxy Server PEM File that the tunnel or clients can use to connect to the queryable mongod instance.

  3. Optional. Update other queryable snapshot settings as appropriate. For description of the settings, see Queryable Snapshot Configuration.

    Note

    After updating Proxy Server Port, the Web Server needs a restart for the new port to take effect.

Query Backup (Use Tunnel to Connect)

Note

The tunnel handles the security (TLS/SSL and X.509 authentication) for connecting to the instance.

1

Go to Backup view and click the Overview tab.

For the deployment whose backup you want to query, click the ellipsis button under Options column and select Query.

You can also click the deployment to view its snapshots and click the Query button under the Actions column.

2

Follow the prompts to query a backup snapshot.

  1. Select the snapshot to query and click Next.

  2. Start the process to query a snapshot. You will be prompted for 2-factor verification.

  3. Select Backup Tunnel as the connection method to the queryable snapshot.

  4. Select your Platform and download.

  5. Uncompress the downloaded file.

  6. Open a terminal or command prompt and go to the uncompressed <tunnel> directory. Run the executable to start the tunnel.

    The default port for the tunnel is 27017. To change the port, use the --local flag, as in the following example:

    ./<tunnel executable> --local localhost:27020
    

    Note

    If you change the port, you must include the port information when connecting.

    For the full list of options you can pass to the tunnel, run the tunnel exectuable with the -h option:

    ./<tunnel executable> -h
    
  7. Use the mongo shell or a MongoDB driver to connect to the backup via the tunnel.

    • If connecting locally from the same machine as where the tunnel is running, you do not need to specify a connection string or host information. Otherwise, specify a connection string or host information for the machine where the tunnel is running.
    • If you have changed the port that the tunnel is listening on, you must specify the port information when connecting.

Tip

Once you have finished querying this snapshot, you can terminate the queryable instance:

  1. Go to the Restore History and hover over the Status column for the deployment item.
  2. Click Cancel.

Query Backup (Handle TLS and Authentication Manually)

Note

The client X.509 certificate is valid for the same length of time as the queryable instance Expiration (Hours), which is 24 hours by default.

1

Go to Backup view and click the Overview tab.

For the deployment whose backup you want to query, click the ellipsis button under Options column and select Query.

You can also click the deployment to view its snapshots and click the Query button under the Actions column.

2

Follow the prompts to query a backup snapshot.

  1. Select the snapshot to query and click Next.

  2. Start the process to query a snapshot. If prompted for your password, enter your password to verify.

  3. Select Connect Manually as the connection method to the queryable snapshot.

  4. Download the X.509 client PEM file.

  5. Download the Certificate Authority (CA) PEM file.

  6. Use the mongo shell or a MongoDB driver to connect to the queryable backup host. To connect, you must specify the hostname and port, the TLS/SSL option, and the X.509 certificates.

    For example, if using the mongo shell to connect to the instance:

    mongo my-queryable-backup-host.mongodb.com:27217 --ssl --sslPEMKeyFile <client certificate> --sslCAFile mms-backup-ca.pem
    

Tip

Once you have finished querying this snapshot, you can terminate the queryable instance:

  1. Go to the Restore History and hover over the Status column for the deployment item.
  2. Click Cancel.

Next Steps

To restore a database or a collection using the queryable backup MongoDB instance, see Restore a Database or Collection from Queryable Backup.