ApsaraDB for MongoDB automatically backs up instances by using parameters of the default backup policy such as the default backup retention period and time. You can also specify a custom backup policy to back up ApsaraDB for MongoDB instances based on your needs. This topic describes how to configure automatic backup for an ApsaraDB for MongoDB instance.

Prerequisites

An ApsaraDB for MongoDB standalone instance, replica set instance, or sharded cluster instance is created.

Background information

ApsaraDB for MongoDB stores backup files in Object Storage Service (OSS) to reduce the storage usage of ApsaraDB for MongoDB instances. For more information about OSS, see What is OSS?

Automatic backup

  • ApsaraDB for MongoDB provides the following default automatic backup methods:
    • Snapshot Backup: The state of disk data at a specific point in time is retained. This method allows data in a database to be restored within minutes.
    • Physical Backup: Physical database files of an ApsaraDB for MongoDB instance are backed up. This method provides faster backup and restoration than logical backup.
  • The following table describes the automatic backup methods for ApsaraDB for MongoDB instances of different architectures.
    Instance architecture Backup method
    • Standalone instance
    • Replica set instances that run MongoDB 5.0 or 4.4
    Snapshot Backup
    Note Snapshot backup affects the I/O performance of ApsaraDB for MongoDB instances.
    • Replica set instances that run MongoDB 4.2 or earlier
    • Sharded cluster instances
    Physical Backup
    Note
    • Physical backup takes place in the hidden node of an ApsaraDB for MongoDB instance, and the read and write performance of the primary and secondary nodes is not affected.
    • If the amount of data to be backed up is large, the backup process requires a long period of time.

Billing

The backup feature of ApsaraDB MongoDB is provided by Data Backup (DBS) and you are charged on a pay-as-you-go basis for the backup storage capacity that exceeds the free quota. For more information about billing rules, see Pricing tab of the ApsaraDB for MongoDB product page.

The free quota:
  • Dedicated cloud disk instances: You are charged on a pay-as-you-go basis when your storage space exceeds 200% of the instance storage capacity.
  • Dedicated local disk instances: You are charged on a pay-as-you-go basis when your storage space exceeds 50% of the instance storage capacity.

Precautions

If the database version of your ApsaraDB for MongoDB instance is earlier than MongoDB 4.0 and the backup method is set to Physical Backup, physical backups may fail when the total number of collections and indexes exceeds 10,000. 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 MongoDB versions.
Note After the database version is upgraded, the backup files of the source instance cannot be used to restore data to the new instance.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and region to which the instance belongs.
  3. In the left-side navigation pane, click Replica set instances or Sharded cluster instance based on the instance type.
  4. On the page that appears, find the instance that you want to manage and click its ID.
  5. In the left-side navigation pane, click Backup and Recovery.
  6. Click the Full Backup tab.
  7. Specify a backup policy.
    1. Click Backup Settings.
    2. In the Backup Settings panel, configure the following parameters.
      Parameter Description
      Full Backup Retention Period (Days) The retention period for full backups. Valid values: 7 to 730. Unit: days. The default value is 30 for ApsaraDB for MongoDB instances created after September 10, 2021.
      Backup Time The period of time during which you want backup tasks to be performed. You can specify an hour that is during off-peak hours.
      Day of Week The days of the week for which you want backup tasks to be performed. You can specify two to seven days for backups to be performed each week. The default value is seven days per week.
      Note
      • If your current backup frequency is one day per week, we recommend that you change it to two or more days per week. A backup frequency of two or more days per week can ensure reliable data restoration, improve data security, and reduce data restoration time in extreme cases.
      • After you manually specify a backup frequency of two or more days per week, you cannot set a new backup frequency of one day per week.
      Log Backup You can enable or disable the Log Backup feature. By default, this feature is enabled.
      • After you enable the Log Backup feature, oplog data is uploaded to OSS in real time and is billed. You can restore (clone) data to a new instance by using the point-in-time data restoration feature.

        You can specify the retention period for backup logs and click the Log Backup tab to view the details of backup logs.

      • After you enable the Log Backup feature, oplog data is not upload OSS and no log backup fees are incurred. Lack of oplogs causes inaccurate data when the point-in-time data restoration method is used. If you clone data to a new instance by using the point-in-time data restoration feature, we recommend that you enable the Log Backup feature.
      Note The Log Backup feature is supported for replica set instances and sharded cluster instances but not for standalone instances.
      Log Backup Retention Period (Days) When you enable the Log Backup feature, you must specify the retention period for log backups. Valid values: 7 to 730. Unit: days. Default value: 7.
      Note The retention period for log backups cannot be longer than the retention period for full backups.
    3. Click OK.

FAQ

How do I view the fees incurred for instance backup?

You can perform the following steps to view the fees:
  1. Log on to the ApsaraDB for MongoDB console.
  2. In the left-side navigation pane, choose Spending Summary > Spending Summary.
  3. Click the Details tab.
  4. Find BackupStorageSize in the Billing Item column. This is the fees incurred for instance backup.

Related API operations

Operation Description
DescribeBackupPolicy Queries the backup policy of an ApsaraDB for MongoDB instance.
ModifyBackupPolicy Modifies the backup policy of an ApsaraDB for MongoDB instance.