If you accidentally delete a collection or document, you can quickly recover data by restoring one or more databases on your ApsaraDB for MongoDB instance.
Prerequisites
The instance must be a replica set instance with cloud disks, a sharded cluster instance with cloud disks, or a replica set instance with local disks.
The database and collection restoration feature for replica set and sharded cluster instances with cloud disks is not generally available. To use this feature, submit a ticket to request its activation.
Database and collection restoration
The following sections describe usage notes, billing, and procedures for each instance architecture.
Cloud disk instances
Usage notes
-
You can restore data from one or more databases only to the source instance.
-
Ensure that a valid backup set exists before you perform a database and collection restoration.
-
Ensure that the source instance has sufficient storage space. If space is insufficient, upgrade the instance specifications first. For more information, see Change the configurations of a sharded cluster instance.
-
During restoration, the system creates temporary collections in the source instance to store the restored data. After the restoration is complete, you can decide whether to overwrite the original databases and collections.
-
Restoration time depends on factors such as data volume, task queue, and network conditions. Wait until the source instance status changes to Running.
-
The database and collection restoration feature does not support databases or collections with names containing special characters. We recommend that you use only letters, numbers, and underscores (_) in database and collection names.
Billing
No additional fees are charged for database and collection restoration, except for backup file storage. For more information, see Billing overview.
Enable database and collection restoration
You must enable the database and collection restoration feature before you can use it. Once enabled, this feature cannot be disabled.
-
Go to the ApsaraDB for MongoDB Replica Set Instances or Sharded Cluster Instances page, select a resource group and a region in the top navigation bar, and then click the ID of the target instance.
-
In the left-side navigation pane of the target instance page, click Backup and Restoration.
-
Click the Backup Settings tab.
-
In the Backup Settings panel, find the Advanced Features section and select Database and Collection Restoration.
-
Click Confirm.
Restore specific databases and collections
-
Go to the ApsaraDB for MongoDB Replica Set Instances or Sharded Cluster Instances page, select a resource group and a region in the top navigation bar, and then click the ID of the target instance.
-
In the left-side navigation pane of the target instance page, click Backup and Restoration.
-
Click Create Instance by Time Point.
-
In the Create Instance by Time Point panel, set Recovery Mode to Database and Collection Restoration.
-
In the Database and Collection Restoration dialog box, specify the Restoration Time and select the Database and Collection to Restore. Then, click Confirm.
-
Click Confirm. The instance's status changes to Restoring. When the instance status changes to Running, the restoration is complete.
-
(Optional) Based on your business requirements, decide whether to overwrite the original collections with the temporary collections.
Local disk instances
Limitations
-
Creation date: The instance must be created after March 26, 2019.
-
Region: The instance must reside in one of the following regions: China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Hangzhou), China (Shanghai), China (Shenzhen), or Singapore.
-
Database version: The instance must run MongoDB 4.0 or 4.2.
Note-
If the database version of your instance is earlier than 4.0, you can upgrade the major version of the instance. For more information, see Upgrade the major version of an ApsaraDB for MongoDB instance.
-
After you upgrade the database version, you cannot use backup sets created before the upgrade to create new instances.
-
-
Storage engine: The instance must use the WiredTiger storage engine.
-
The backup set must contain the database that you want to restore. For example, if you want to restore the
testdatabase of an instance, the backup set must contain thetestdatabase. -
The database and collection restoration feature does not support databases or collections with names containing special characters. We recommend that you use only letters, numbers, and underscores (_) in database and collection names.
Usage notes
-
You can restore one or more databases only from a physical backup, not from a logical backup. If you have an ApsaraDB for MongoDB 3.4 instance with more than 10,000 collections and indexes in total, physical backups may fail. You can upgrade the major version to 4.0 or later before performing a physical backup. For more information, see Upgrade the major version of an ApsaraDB for MongoDB instance.
NoteAfter the database version is upgraded, backup sets created before the upgrade cannot be used to create new instances.
-
Restoration time depends on factors such as data volume, task queue, and network conditions. Wait until the status of the new instance changes to Running.
-
For improved performance and stability, the new instance created during restoration defaults to the latest minor database version.
Billing
Restoring one or more databases creates a new instance, which incurs charges. For more information, see Billable items.
Procedure
-
Go to the ApsaraDB for MongoDB Replica Set Instances page, select a resource group and a region in the top navigation bar, and then click the ID of the target instance.
-
In the left-side navigation pane of the target instance page, click Backup and Restoration.
-
On the Full Backup tab, restore data either to a point in time or from a backup set, based on your business requirements.
Restore by time point
-
Click Create Instance by Time Point.
-
In the Create Instance by Time Point panel, configure the following parameters.
Parameter
Description
Select Time Point for Restoration
Select a point in time to restore the data. You can select any point in time within the last seven days.
NoteThe restoration time must be earlier than the current time and later than the instance creation time.
Select Database for Restoration
Select Partial Databases and then select the databases to restore.
NoteYou can also click Enter Databases to manually enter the databases that you want to restore.
-
Click OK.
Restore from backup set
-
From the list of full backups, find the target backup set and click Create Instance from Backup in the Actions column.
-
In the Create Instance from Backup panel, select Partial Databases and then select the databases to restore.
NoteYou can also click Enter Databases to manually enter the databases that you want to restore.
-
Click OK.
-
-
On the Clone Instance page, configure the new instance based on your requirements. For more information about the configuration parameters, see Create a replica set instance.
NoteTo ensure the new instance has sufficient space for the restored data, configure a storage space at least as large as the source instance's.
-
Click Buy Now and follow the prompts to complete the payment.