Recover accidentally deleted collections or documents by restoring specific databases from a backup, without replacing the entire instance.
Prerequisites
Before you begin, make sure that:
Your instance is one of the following types:
Replica set instance with cloud disks
Sharded cluster instance with cloud disks
Replica set instance with local disks
A valid backup exists for the instance.
The database and collection restoration feature for cloud disk instances is not available to all users. If you want to use this feature, submit a ticket to technical support to enable it.
Which procedure applies to you?
| Instance type | Where data is restored | Billing |
|---|---|---|
| Replica set with cloud disks | To the original instance | Free (you pay only for backup storage) |
| Sharded cluster with cloud disks | To the original instance | Free (you pay only for backup storage) |
| Replica set with local disks | To a new instance | You are billed for the new instance |
Cloud disk instances (replica set and sharded cluster)
Limitations
Data can only be restored to the original instance, not to a new one.
The original instance must have enough storage space. If not, scale out the instance before proceeding.
During restoration, the system creates temporary tables in the original instance. After restoration completes, you can choose whether to overwrite the original tables.
Database and collection names must not contain special characters. Use only letters, numbers, and underscores (
_).Restoration time depends on data volume, the task queue, and network conditions. Wait until the instance status changes to Running.
Billing
The database and collection restoration feature is free. You pay only for backup file storage. For details, see Billing rules.
Step 1: Enable database and collection restoration
Enable this feature before using it. Once enabled, it cannot be disabled.
Go to the ApsaraDB for MongoDB replica set instances page or the ApsaraDB for MongoDB sharded cluster instances page. In the upper-left corner, select a resource group and a region, then click the target instance ID.
In the left-side navigation pane, click Backup and Restoration.
Click Backup Settings, then click Edit next to Basic Backup.
In the Backup Settings panel, under Advanced Features, select Database and Collection Restoration.
Click OK.
Step 2: Perform a full backup
Database and collection metadata is included in full backups. After enabling the feature, run a full backup before restoring any data. The backup can be automatic (scheduled) or manual (on demand).
Step 3: Restore databases
Go to the ApsaraDB for MongoDB replica set instances page or the ApsaraDB for MongoDB sharded cluster instances page. In the upper-left corner, select a resource group and a region, then click the target instance ID.
In the left-side navigation pane, click Backup and Restoration.
Click Create Instance by Time Point.
In the Create Instance by Time Point panel, set Restoration Mode to Database and Collection Restoration.
In the Database and Collection Restoration dialog box, select a Restoration Time and the Database and Collection to Restore, then click OK.
The instance status changes to Restoring from Backup. Wait until it changes back to Running.
(Optional) Decide whether to overwrite the original tables with the restored temporary tables.
Local disk replica set instances
Limitations
| Constraint | Requirement |
|---|---|
| Instance creation date | After March 26, 2019 |
| Supported regions | China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Hangzhou), China (Shanghai), China (Shenzhen), or Singapore |
| Database version | 4.0 or 4.2 |
| Storage engine | WiredTiger only |
| Backup type | Physical backups only — logical backups are not supported |
| Database/collection names | Letters, numbers, and underscores (_) only — no special characters |
If your database version is earlier than 4.0, upgrade the major version first. After upgrading, backup files created before the upgrade cannot be used to create new instances.
If your instance runs MongoDB 3.4 and has more than 10,000 collections and indexes, physical backups may fail. Upgrade to MongoDB 4.0 or later before performing a physical backup.
Additional notes:
The backup must contain the specific database you want to restore. For example, to restore the
testdatabase, the backup file must includetest.Restoration time depends on data volume, the task queue, and network conditions. Wait until the new instance status changes to Running.
The new instance uses the latest minor database version by default.
Billing
Restoring databases creates a new instance, which you are billed for. For pricing details, see Billable items.
Restore databases
Go to the ApsaraDB for MongoDB replica set instances page. In the upper-left corner, select a resource group and a region, then click the target instance ID.
In the left-side navigation pane, click Backup and Restoration.
On the Full Backup tab, choose a restoration method:
Restore by time point
Click Create Instance by Time Point.
In the Create Instance by Time Point panel, set the following parameters.
Parameter
Description
Select Time Point for Restoration
Select a point in time to restore the instance 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 select the names of the databases that you want to restore.
NoteYou can also click Enter Databases to manually enter the database names.
Click OK.
Restore from a backup point
In the backup file list, find the target backup file and click Create Instance from Backup in the Actions column.
In the Create Instance from Backup panel, select Partial Databases, then select the database names. To enter names manually, click Enter Databases.
NoteYou can also click Enter Databases to manually enter the database names.
Click OK.
On the Clone Instance page, configure the new instance. For configuration details, see Create a replica set instance.
ImportantSet the storage capacity to at least the same size as the original instance to make sure the restored data fits.
Click Buy Now and complete the payment.
What's next
To prevent accidental data loss, configure automated backups with an appropriate retention period. See Configure automatic backup for an instance.
To restore an entire instance rather than specific databases, see Restore an ApsaraDB for MongoDB instance.