Managing backups
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.
To restore an existing cluster from a backup:
- Go to the folder page and select Managed Service for MongoDB.
- Click on the name of the cluster you need and select the tab Backup copies.
- Click for the backup and click Restore cluster.
- Set up the new cluster. You can select a folder for the new cluster from the Folder list.
- Click Restore cluster.
To restore a previously deleted cluster from a backup:
- Go to the folder page and select Managed Service for MongoDB.
- Click the Backups tab.
- Find the desired backup using the backup creation time and cluster ID. The Name column contains the IDs in
<cluster ID>:<backup ID>
format. - Click for the backup and click Restore cluster.
- Set up the new cluster. You can select a folder for the new cluster from the Folder list.
- 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:
-
View the description of the CLI's restore cluster command MongoDB:
$ yc managed-mongodb cluster restore --help
-
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, inyyyy-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. -
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
-
Go to the folder page and select Managed Service for MongoDB.
-
Click on the name of the cluster you need and select the tab Backup copies.
-
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:
-
View a description of the CLI create MongoDB backup command:
$ yc managed-mongodb cluster backup --help
-
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
To get a list of cluster backups:
- Go to the folder page and select Managed Service for MongoDB.
- 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:
- Go to the folder page and select Managed Service for MongoDB.
- Click the Backups tab.
These lists contain the following information:
- Backup name.
- Source shard.
- Backup size.
- Backup type:
Automated
orManual
. - 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
orManual
.
Getting information about backups
To get information about the backup of an existing cluster:
- Go to the folder page and select Managed Service for MongoDB.
- 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:
- Go to the folder page and select Managed Service for MongoDB.
- 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 theru-central1-c
availability zone andb0rcctk2rvtr8efcch63
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.
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