To restore a collection or document that was accidentally deleted, you can restore one or more databases of an ApsaraDB for MongoDB instance.

Prerequisites

  • The instance must meet the following requirements:
    • The instance was created after March 26, 2019.
    • The instance is a replica set instance.
    • The instance belongs to the China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Hangzhou), China (Shanghai), China (Shenzhen), or Singapore (Singapore) region.
    • The instance runs MongoDB 3.4, 4.0, or 4.2.
      Note
      • If the MongoDB version that your instance runs is outdated, upgrade the version. For more information, see Upgrade MongoDB versions.
      • After the upgrade, the instance backup files generated before the upgrade cannot be used to create instances.
    • The storage engine of the instance is WiredTiger.
  • Backup files contain the data of the databases to be restored. For example, if you want to restore the test database, the data of the test database must be included in the backup files.

Precautions

  • You can restore one or more databases only from physical backups. If your instance runs MongoDB 3.4 and the total number of collections and indexes in your instance exceeds 10,000, physical backups may fail. Before you implement a physical backup, upgrade the MongoDB version of your instance to 4.0 or later. For more information about how to upgrade the database version, see Upgrade MongoDB versions.
    Note After the upgrade, instance backup files that were generated before the upgrade cannot be used to create instances.
  • The amount of time required to restore one or more databases varies based on factors such as data volume, task queue state, and network condition. When the state of the new instance changes to Running, the restoration is complete.
  • If the minor version of an instance expires or is not included in the maintenance list, ApsaraDB for MongoDB automatically updates the minor version of the instance to the latest version when you perform the following operations. This ensures the performance and stability of the instance.

Billing

When you restore one or more databases, the system creates an instance and you are charged for this instance. For more information, see Billable items and pricing.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the left-side navigation pane, click Replica Set Instances.
  3. In the upper-left corner of the page, select the resource group and region to which the instance belongs.
  4. On the page that appears, find the instance that you want to manage and click its ID.
  5. Click the ID of an instance, or click More icon in the Actions column corresponding to the instance and select Manage.
  6. Click the Full Backup tab.
  7. Use one of the following methods to restore databases:
    • Create an instance by point in time
      1. Click Create Instance By Time Point.
      2. In the Create Instance By Time Point panel, specify the following parameters.
        Parameter Description
        Select recovery time point Select a point in time from the last seven days from which to restore data.
        Note The point in time you select must be earlier than the current time and later than the time when the source instance was created.
        Select databases to recover Select Select Databases and then select the names of the databases that you want to restore.
        Note You can also click Enter Databases and enter the names of the databases that you want to restore.
      3. Click OK.
    • Create an instance from a backup point
      1. Find the backup file that you want to restore and click Create Instance from Backup Point in the Actions column.
      2. In the Create Instance from Backup Point panel, select Select Databases and then select the databases that you want to restore.
        Note You can also click Enter Databases and enter the names of the databases that you want to restore.
      3. Click OK.
  8. Configure the new instance.
    1. On the Clone Instance page, set Product Type.
      • Replica Set (Subscription): If you purchase a subscription instance, you must pay an upfront fee. For long-term usage, the subscription billing method is more cost-effective than the pay-as-you-go billing method. You are provided with larger discounts for longer subscription periods.
      • Replica Set (Pay-as-you-go): A pay-as-you-go instance is charged on an hourly basis as per its configurations. Fees are automatically deducted from your Alibaba Cloud account. We recommend that you select the pay-as-you-go billing method for short-term usage. If you no longer require a pay-as-you-go instance, you can release it to reduce costs.
    2. Configure the new instance. For more information, see Create a replica set instance.
      Note
      • When you create the instance, the Region, Engine Version, Active-standby Nodes, Storage Engine, Storage Type, or Network Type parameter cannot be changed.
      • To ensure that the new instance has sufficient capacity for restoration, we recommend that you set the storage capacity to a value that is greater than or equal to that of the instance that you want to restore.
  9. Confirm the order and complete the payment.
    1. Read and select the ApsaraDB for MongoDB Terms of Service and click Buy Now.
    2. Pay for the instance based on the billing method.
      • Subscription: On the Purchase page, check the configured parameters, click Subscribe, and then complete the payment.
      • Pay-as-you-go: After you click Buy Now, the system automatically collects the amount in the next hour.