Hot Backup

Percona Server for MongoDB includes an integrated open-source hot backup system for the default WiredTiger storage engine. It creates a physical data backup on a running server without notable performance and operating degradation.

To take a hot backup of the database in your current dbpath, run the createBackup command as administrator on the admin database and specify the backup directory.

> use admin
switched to db admin
> db.runCommand({createBackup: 1, backupDir: "/my/backup/data/path"})
{ "ok" : 1 }

If the backup was successful, you should receive an { "ok" : 1 } object. If there was an error, you will receive a failing ok status with the error message, for example:

> db.runCommand({createBackup: 1, backupDir: ""})
{ "ok" : 0, "errmsg" : "Destination path must be absolute" }

Saving a Backup to a TAR Archive

Implementation details

This feature was implemented in Percona Server for MongoDB 4.0.12-6.

To save a backup in the format of tar archive, use the archive field to specify the destination path:

> use admin
...
> db.runCommand({createBackup: 1, archive: "path/to/archive.tar" })

Streaming Hot Backups to a Remote Destination

Implementation details

This feature was implemented in Percona Server for MongoDB 4.0.12-6. In this release, this feature has the EXPERIMENTAL status.

Starting from version 4.0.12-6, Percona Server for MongoDB enables uploading hot backups to an Amazon S3 or a compatible storage service, such as MinIO.

This method requires that you provide the bucket field in the s3 object:

> use admin
...
> db.runCommand({createBackup: 1, s3: {bucket: "backup20190510", path: "some/optional/path"} })

In addition to the mandatory bucket field, the s3 object may contain the following fields:

Field Type Description
bucket string The only mandatory field. Names are subject to restrictions described in the Bucket Restrictions and Limitations section of Amazon S3 documentation
path string The virtual path inside the specified bucket where the backup will be created. If the path is not specified then the backup is created in the root of the bucket. If there are any objects under the specified path, the backup will not be created and an error will be reported.
endpoint string The endpoint address and port - mainly for AWS S3 compatible servers such as the MinIO server. For a local MinIO server, this can be “127.0.0.1:9000”. For AWS S3 this field can be omitted.
scheme string “HTTP” or “HTTPS” (default). For a local MinIO server started with the minio server command this should field should contain HTTP.
useVirtualAddressing bool The style of addressing buckets in the URL. By default ‘true’. For MinIO servers, set this field to false. For more information, see Virtual Hosting of Buckets in the Amazon S3 documentation.
region string The name of an AWS region. The default region is US_EAST_1. For more information see AWS Service Endpoints in the Amazon S3 documentation.
profile string The name of a credentials profile in the credentials configuration file. If not specified, the profile named default is used.
accessKeyId string The access key id
secretAccessKey string The secret access key

Credentials

If the user provides the access key id and the secret access key parameters, these are used as credentials.

If the access key id parameter is not specified then the credentials are loaded from the credentials configuration file. By default, it is ~/.aws/credentials.

An example of the credentials file

[default]
aws_access_key_id = ABC123XYZ456QQQAAAFFF
aws_secret_access_key = zuf+secretkey0secretkey1secretkey2
[localminio]
aws_access_key_id = ABCABCABCABC55566678
aws_secret_access_key = secretaccesskey1secretaccesskey2secretaccesskey3

Examples

Backup in Root of Bucket on Local Instance of MinIO Server

> db.runCommand({createBackup: 1,  s3: {bucket: "backup20190901500",
scheme: "HTTP",
endpoint: "127.0.0.1:9000",
useVirtualAddressing: false,
profile: "localminio"}})

Backup on MinIO Testing Server With Default Credentials Profile

The following command creates a backup under the virtual path “year2019/day42” in the backup bucket:

> db.runCommand({createBackup: 1,  s3: {bucket: "backup",
path: "year2019/day42",
endpoint: "sandbox.min.io:9000",
useVirtualAddressing: false}})

Backup on AWS S3 Service Using Default Settings

> db.runCommand({createBackup: 1,  s3: {bucket: "backup", path: "year2019/day42"}})

See also

AWS Documentation: Providing AWS Credentials
https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/credentials.html