If you accidentally delete a single collection or document in an ApsaraDB for MongoDB instance, you can restore the collection or document by restoring the databases that store it.
Prerequisites
The instance is a sharded cluster instance that uses cloud disks or a replica set instance that uses local disks.
The database and collection restoration feature is not available to all users of sharded cluster instances that use cloud disks. To use the feature, submit a ticket.
Restore databases
The usage notes, billing rules, and operations for restoring databases vary with the instance architecture.
Sharded cluster instances that use cloud disks
Usage notes
You can restore databases only to the original instance.
Before you restore databases, make sure that backup sets are available.
Before you restore databases, make sure that the original instance has sufficient storage capacity. If the storage capacity is insufficient to store the data, scale up the storage capacity in advance. For more information, see Change the configurations of one or more shard nodes.
When you restore databases, ApsaraDB for MongoDB creates a temporary collection in the original instance to store the restored data. After the restoration is complete, you can specify whether to overwrite original databases based on your business requirements.
The amount of time required to restore databases varies based on factors such as data volume, task queue status, and network condition. When the status of the new instance changes to Running, the restoration is complete.
Billing rules
You are charged only storage fees for backup files when you use the database and collection restoration feature. For more information about backup fees, see Billing rules.
Enable the database and collection restoration feature
You need to manually enable the database and collection restoration feature by performing the following steps. You cannot disable the feature after you enable it.
Go to the Sharded Cluster Instances page. In the top navigation bar, select the region in which the instance resides. Then, find the instance and click the ID of the instance.
In the left-side navigation pane of the instance details page, click Backup and Restoration.
Click Backup Settings.
In the Advanced Features section of the Backup Settings panel, select Database and Collection Restoration.
Click OK.
Restore specific databases to the original instance
Go to the Sharded Cluster Instances page. In the top navigation bar, select the region in which the instance resides. Then, find the instance and click the ID of the instance.
In the left-side navigation pane of the instance details page, click Backup and Restoration.
Click Create Instance by Time Point.
In the Create Instance by Time Point panel, set the Restoration Mode parameter to Database and Collection Restoration.
In the Database and Collection Restoration dialog box, configure the Restoration Time and Database and Collection to Restore parameters. Then, click OK.
After you click OK, the status of the instance changes to Restoring. When the status of the new instance changes to Running, the restoration is complete.
(Optional) You can specify whether to overwrite original collections with a temporary collection based on your business requirements.
Replica set instances that use local disks
Limits
The instance must be created after March 26, 2019.
The instance must be deployed in the China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Hangzhou), China (Shanghai), China (Shenzhen), or Singapore region.
Only MongoDB 3.4, 4.0, or 4.2 are supported.
NoteIf the instance runs an earlier major version, you can upgrade the major version of the instance. For more information, see Upgrade the major version of an ApsaraDB for MongoDB instance.
After the upgrade, the instance backup files generated before the upgrade cannot be used to create instances.
The storage engine of the instance must be WiredTiger.
Backup files used for restoration must contain the data of the database that you want to restore in the instance. For example, if you want to restore a database named test in an instance, backup files used for restoration must contain the data of the test database.
Usage notes
You can restore databases only from physical backups. Logical backups are not supported. If your instance runs MongoDB 3.4 and contains more than 10,000 collections and indexes in total, physical backups may fail. Before you implement a physical backup, upgrade the database version of your instance to MongoDB 4.0 or later. For more information about how to upgrade the database version, see Upgrade the major version of an ApsaraDB for MongoDB instance.
NoteAfter the upgrade, the instance backup files generated before the upgrade cannot be used to create instances.
The amount of time required to restore databases varies based on factors such as data volume, task queue status, and network condition. When the status of the new instance changes to Running, the restoration is complete.
To improve performance and stability, the latest minor version is used for a new instance created during restoration by default.
Billing rules
When you restore databases, a new instance is created. You are charged fees for the instance. For more information, see Billable items.
Procedure
Go to the Replica Set Instances page. In the top navigation bar, select the region in which the instance resides. Then, find the instance and click the ID of the instance.
In the left-side navigation pane of the instance details page, click Backup and Restoration.
On the Full Backup tab, select point-in-time restoration or backup-point restoration.
Restoration by point in time
Click Create Instance by Time Point.
In the Create Instance by Time Point panel, configure the parameters described in the following table.
Parameter
Description
Select Time Point for Restoration
Select a point in time within the last seven days from which you want to restore data.
NoteThe point in time that you select must be earlier than the current time and later than the time when the original instance was created.
Select Database for Restoration
Select Partial Databases and then select the names of the databases that you want to restore.
NoteYou can also click Enter Databases to enter the names of the databases that you want to restore.
Click OK.
Restoration by backup point
In the backup file list, find the backup file that you want to use for restoration and click Create Instance from Backup in the Actions column.
In the Create Instance from Backup panel, select Partial Databases and then select the names of the databases that you want to restore.
NoteYou can also click Enter Databases to enter the names of the databases that you want to restore.
Click OK.
On the Clone Instance page, complete the configurations of a new instance. For more information about the configuration items of a new instance, see Create a replica set instance.
NoteTo ensure that the new instance has sufficient storage capacity for restoration, we recommend that you select the storage capacity greater than or equal to that of the original instance for the new instance.
Click Buy Now and follow the instructions to complete the payment.