All Products
Search
Document Center

ApsaraDB for MongoDB:Restore the databases of an ApsaraDB for MongoDB instance

Last Updated:Jun 28, 2024

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.

Note

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.

  1. 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.

  2. In the left-side navigation pane of the instance details page, click Backup and Restoration.

  3. Click Backup Settings.

  4. In the Advanced Features section of the Backup Settings panel, select Database and Collection Restoration.

  5. Click OK.

Restore specific databases to the original instance

  1. 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.

  2. In the left-side navigation pane of the instance details page, click Backup and Restoration.

  3. Click Create Instance by Time Point.

  4. In the Create Instance by Time Point panel, set the Restoration Mode parameter to Database and Collection Restoration.

  5. In the Database and Collection Restoration dialog box, configure the Restoration Time and Database and Collection to Restore parameters. Then, click OK.

  6. 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.

  7. (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.

    Note
  • 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.

    Note

    After 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

  1. 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.

  2. In the left-side navigation pane of the instance details page, click Backup and Restoration.

  3. On the Full Backup tab, select point-in-time restoration or backup-point restoration.

    Restoration by point in time

    1. Click Create Instance by Time Point.

    2. 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.

      Note

      The 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.

      Note

      You can also click Enter Databases to enter the names of the databases that you want to restore.

    3. Click OK.

    Restoration by backup point

    1. 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.

    2. In the Create Instance from Backup panel, select Partial Databases and then select the names of the databases that you want to restore.

      Note

      You can also click Enter Databases to enter the names of the databases that you want to restore.

    3. Click OK.

  4. 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.

    Note

    To 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.

  5. Click Buy Now and follow the instructions to complete the payment.