Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Managed Service for MongoDB
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • Database migration to Yandex.Cloud
    • Connecting to databases
    • Stopping and starting clusters
    • Changing cluster and database settings
    • MongoDB version upgrade
    • Database management
    • Managing hosts in a cluster
    • Managing database users
    • Managing backups
    • Managing shards
    • Deleting clusters
  • Solutions
    • Sharding collections
  • Concepts
    • Relationship between service resources
    • Host classes
      • Active host classes
      • Archive
        • Before June 1, 2020
      • Using deprecated host classes
    • Network in Yandex Managed Service for MongoDB
    • Quotas and limits
    • Storage types
    • Backups
    • Replication
    • Sharding
    • Users and roles
    • Supported clients
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
      • From March 1, 2019 to February 1, 2020
  • API reference
    • Authentication in the API
    • gRPC
      • Обзор
      • BackupService
      • ClusterService
      • DatabaseService
      • ResourcePresetService
      • UserService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • addShard
        • backup
        • create
        • delete
        • deleteHosts
        • deleteShard
        • enableSharding
        • get
        • getShard
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • listShards
        • move
        • rescheduleMaintenance
        • resetupHosts
        • restartHosts
        • restore
        • start
        • stop
        • streamLogs
        • update
      • Database
        • Overview
        • create
        • delete
        • get
        • list
      • ResourcePreset
        • Overview
        • get
        • list
      • User
        • Overview
        • create
        • delete
        • get
        • grantPermission
        • list
        • revokePermission
        • update
      • Operation
        • Overview
        • get
  • Questions and answers
    • General questions
    • Questions about MongoDB
    • All questions on the same page
  1. Step-by-step instructions
  2. Managing backups

Managing backups

  • Restoring clusters from backups
  • Creating backups
  • Getting a list of backups
  • Getting information about backups
  • Examples

You can create backups and restore clusters from existing backups.

Restoring clusters from backups

Point-in-Time Recovery (PITR) technology lets you restore the cluster state to any point in time in the interval from its backup to the current point. For example, if the backup operation ended August 10, 2020, 12:00:00 UTC and the current date is August 15, 2020, 19:00:00 UTC, the cluster can be restored to any state between August 10, 2020, 12:00:01 UTC and August 15, 2020, 18:59:59 UTC inclusive.

If the cluster is already deleted, the interval where you can use PITR for recovery is limited to the time of the first and last backup creation. If you attempt to restore such a cluster to a point in time when it was deleted, it is the same as restoring from the latest backup.

Warning

Note:

  • PITR only works for clusters with version 4.2 and higher.
  • PITR is not supported for clusters with sharding enabled. Such clusters can be restored only to the point in time when the selected backup was created.

To learn more about this technology, see Backups.

When you restore a cluster from a backup, you create a new cluster with the data from the backup. If the folder has insufficient resources to create such a cluster, you will not be able to restore from the backup. The average backup recovery speed is 10 MBps.

For a new cluster, you should set all the parameters that are required at creation, except for the cluster type (a MongoDB backup cannot be restored as a PostgreSQL cluster).

Note

Point-in-Time-Recovery technology for Managed Service for MongoDB is at the Preview stage: you can only use it when restoring from a backup via the CLI. This restriction is removed at the General Availability stage. The technology is enabled on request.

Management console
CLI

To restore an existing cluster from a backup:

  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click on the name of the cluster you need and select the tab Backup copies.
  3. Click for the backup and click Restore cluster.
  4. Set up the new cluster. You can select a folder for the new cluster from the Folder list.
  5. Click Restore cluster.

To restore a previously deleted cluster from a backup:

  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click the Backups tab.
  3. Find the desired backup using the backup creation time and cluster ID. The Name column contains the IDs in <cluster ID>:<backup ID> format.
  4. Click for the backup and click Restore cluster.
  5. Set up the new cluster. You can select a folder for the new cluster from the Folder list.
  6. Click Restore cluster.

Managed Service for MongoDB launches the operation to create a cluster from a backup.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To restore a cluster from a backup:

  1. View the description of the CLI's restore cluster command MongoDB:

    $ yc managed-mongodb cluster restore --help
    
  2. Getting a list of available MongoDB cluster backups:

    $ yc managed-mongodb backup list
    
    +--------------------------+----------------------+----------------------+----------------------+--------+-----------+
    |            ID            |      CREATED AT      |  SOURCE CLUSTER ID   |      STARTED AT      |  SIZE  |   TYPE    |
    +--------------------------+----------------------+----------------------+----------------------+--------+-----------+
    | c9qlk4v13uq79r9cgcku:... | 2020-08-10T12:00:00Z | c9qlk4v13uq79r9cgcku | 2020-08-10T11:55:17Z | 3.3 KB | AUTOMATED |
    | ...                                                                                           |                    |
    +--------------------------+----------------------+----------------------+----------------------+--------+-----------+
    

    The time when the backup was completed is shown in the CREATED AT column of a list of available backups, in yyyy-mm-ddThh:mm:ssZ format (2020-08-10T12:00:00Z in the example above). You can restore a cluster to any state from the specified point in time to the current time.

  3. Run the command to create a new cluster from a backup (the example shows only some parameters):

     $ yc managed-mongodb cluster restore \
          --backup-id <backup ID> \
          --recovery-target-timestamp <point in time> \
          --mongodb-version "<version MongoDB>" \
          --cluster-name  <new cluster name> \
          --environment <environment, PRESTABLE, or PRODUCTION> \
          --network-name <network name> \
          --host zone-id=<availability zone>,subnet-id=<subnet ID> \
          --mongod-resource-preset <host class> \     
          --mongod-disk-size <storage size in GB> \
          --mongod-disk-type <storage type: network-hdd, network-ssd, or local-ssd>
    

    In the --recovery-target-timestamp parameter, specify the point in time to which you want to restore the MongoDB cluster, in UNIX time format. If you want to restore the cluster state to the backup creation time, you may omit this option.

Creating backups

Management console
CLI
  1. Go to the folder page and select Managed Service for MongoDB.

  2. Click on the name of the cluster you need and select the tab Backup copies.

  3. Click Create a backup.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To create a cluster backup:

  1. View a description of the CLI create MongoDB backup command:

    $ yc managed-mongodb cluster backup --help
    
  2. Request creation of a backup specifying the cluster name or ID:

    $ yc managed-mongodb cluster backup my-mg-cluster
    

    The cluster name and ID can be retrieved with the list of clusters.

Getting a list of backups

Management console
CLI

To get a list of cluster backups:

  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click on the name of the cluster you need and select the tab Backup copies.

To get a list of all backups in a folder:

  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click the Backups tab.

These lists contain the following information:

  • Backup name.
  • Source shard.
  • Backup size.
  • Backup type: Automated or Manual.
  • Start time of backup creation in UTC (Coordinated Universal Time).
  • End time of backup creation in UTC.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To get a list of MongoDB cluster backups available in the default folder, run the command:

$ yc managed-mongodb backup list

+----------+----------------------+----------------------+----------------------+--------+-----------+
|    ID    |      CREATED AT      |  SOURCE CLUSTER ID   |      STARTED AT      |  SIZE  |   TYPE    |
+----------+----------------------+----------------------+----------------------+--------+-----------+
| c9qlk... | 2020-08-10T12:00:00Z | c9qlk4v13uq79r9cgcku | 2020-08-10T11:55:17Z | 3.3 KB | AUTOMATED |
| c9qpm... | 2020-08-09T22:01:04Z | c9qpm90p3pcg71jm7tqf | 2020-08-09T21:30:00Z | 30 KB  | MANUAL    |
+----------+----------------------+----------------------+----------------------+--------+-----------+

The resulting table contains the following information:

  • ID of the backup.
  • End time of backup creation in UTC (Coordinated Universal Time).
  • ID of the cluster that the backup was created for.
  • Start time of backup creation in UTC.
  • Backup size.
  • Backup type: Automated or Manual.

Getting information about backups

Management console
CLI

To get information about the backup of an existing cluster:

  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click on the name of the cluster you need and select the tab Backup copies.

To get information about the backup of a previously deleted cluster:

  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click the Backups tab.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To get information about a MongoDB cluster backup, run the command:

$ yc yc managed-mongodb backup get <backup ID>

The backup ID can be retrieved with the list of backups .

Examples

Let's say we need to create a new MongoDB cluster from a backup with the following characteristics:

  • Backup for recovery: c9qlk4v13uq79r9cgcku:...:stream_20200810T120000Z.
  • Point in time you want to recover to: 1597035610 (2020-08-10T12:00:10Z).
  • Version: 4.2.
  • Name of the new cluster: mynewmg.
  • Environment: PRODUCTION.
  • Network: default.
  • One s2.micro host in the ru-central1-c availability zone and b0rcctk2rvtr8efcch63 subnet.
  • Storage: fast network storage (network-ssd) 20 GB in size.
  • With databases and users that existed in the cluster at the time of recovery.
CLI

To recover from a backup, run the following command:

$ yc managed-mongodb cluster restore \
         --backup-id c9qlk4v13uq79r9cgcku:...:stream_20200810T120000Z \
         --recovery-target-timestamp 1597035610 \
         --mongodb-version "4.2" \
         --cluster-name mynewmg \
         --environment PRODUCTION \
         --network-name default \
         --host zone-id=ru-central1-c,subnet-id=b0rcctk2rvtr8efcch63 \
         --mongod-resource-preset s2.micro \ 
         --mongod-disk-size 20 \
         --mongod-disk-type network-ssd
In this article:
  • Restoring clusters from backups
  • Creating backups
  • Getting a list of backups
  • Getting information about backups
  • Examples
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC