ApsaraDB for MongoDB automatically backs up data in an instance based on the specified instance backup policy. This topic describes how to configure automatic data backup for an instance.

Prerequisites

A standalone instance, replica set instance, or sharded cluster instance is created.

Precautions

  • If the engine version of your 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 in the instance exceeds 10,000. Before you implement a physical backup, upgrade the engine version of your instance to MongoDB 4.0 or later. For more information about how to upgrade the engine version, see Upgrade the major version of an ApsaraDB for MongoDB instance.
    Important After the upgrade, instance backup files that were generated before the upgrade cannot be used to create instances.
  • Single-digit second backup is available only for replica set instances that run MongoDB 5.0 or 4.4.
  • Log backup is available only for replica set and sharded cluster instances.
  • The retention period of log backups cannot be longer than the retention period of full backups.
  • After you disable log backup, log backups are deleted and cannot be restored.

Automatic backup

ApsaraDB for MongoDB stores backup files in Object Storage Service (OSS) buckets instead of ApsaraDB for MongoDB instances.

The following table describes the backup methods for instances of different architectures and engine versions.
InstanceBackup methodDescription
  • Standalone instance
  • Replica set instance that runs MongoDB 5.0 or 4.4
Snapshot backupSnapshot backup retains disk data at a specific point in time and can be used to restore the data within minutes.
Note Snapshot backup consumes the I/O resources of instances.
  • Replica set instance that runs MongoDB 4.2 or earlier
  • Sharded cluster instance
Physical backupPhysical backup stores physical database files of instances.
Note
  • Physical backup takes place in the hidden node of an instance, and the read and write performance of the primary and secondary nodes is not affected.
  • It takes a long time to back up a large amount of physical database files.

Billing

ApsaraDB for MongoDB provides free backup quotas. If your backup storage (both full backup and log backup) falls within the free quota, no fees are charged. For excess usage, you are charged based on the following formula: Backup fee per hour = (Backup usage - Free quota) × Fee per backup-hour. The following table describes the billing details.
Storage typeFree quotaView the storage usage and free quota
Enhanced SSD (ESSD)The free quota is equal to 200% of the storage capacity that you purchase for your instance.You can view the storage usage and free quota in the Specification Information section of the Basic Information page of the instance.
Local SSDThe free quota is equal to 50% of the storage capacity that you purchase for your instance.

For more information about the unit price of backups, see the Pricing tab of the ApsaraDB for MongoDB product page.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the left-side navigation pane, click Replica Set Instances or Sharded Cluster Instances based on the instance type.
  3. In the upper-left corner of the page, select the resource group and region to which the instance belongs.
  4. Click the ID of an instance, or click More icon in the Actions column corresponding to the instance and select Manage.
  5. In the left-side navigation pane of the instance details page, click Backup and Recovery.
  6. Click the Full Backup tab.
  7. Specify a backup policy.
    1. Click the Backup Settings tab.
    2. In the Backup Settings panel, configure the parameters described in the following table.
      ParameterDescription
      Full Backup Retention Period (Days)The retention period of full backups. Valid values: 7 to 730. Unit: days.
      Note By default, this parameter is set to 30 for instances purchased after September 10, 2021.
      Backup Within SecondsSpecifies whether to enable Backup Within Seconds. By default, this feature is disabled.

      If the feature is enabled, a backup operation can be completed within a few seconds.

      Note This feature is available only for replica set instances that run MongoDB 5.0 or 4.4.
      Backup TimeThe period of time during which you want backup tasks to be performed. Unit: hours.
      We recommend that specify an off-peak time period.
      Note The time range displayed is in the same time zone as that of the computer that you use to log on to the ApsaraDB for MongoDB console.
      Day of WeekThe frequency at which data is backed up. The default value is seven times per week.
      Note We recommend that you set the backup frequency to at least two times per week to ensure reliable data restoration and improve data security. This also accelerates your data restoration in extreme cases.
      Log BackupSpecifies whether to enable Log Backup. By default, this feature is enabled.
      • After you enable log backup, oplogs are uploaded to OSS buckets in real time and are billed. You can restore (clone) data to a new instance by using the point-in-time data restoration feature.
        Note
        • You can specify the retention period of log backups and click the Log Backup tab to view the details of log backups.
        • Log backup is available only for replica set and sharded cluster instances.
      • After you disable log backup, oplogs are not uploaded to OSS buckets and no log backup fees are incurred. In this case, oplogs are not retained, and the system selects the full backup that was created at the closest point in time to the specified backup time for restoration. To ensure the accuracy of point-in-time data restoration, we recommend that you enable Log Backup.
        Important After you disable log backup, log backups are deleted and cannot be restored.
      Log Backup Retention Period (Days)If you enable Log Backup, you must specify the retention period of 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

Q: How do I view the fees incurred for instance backup?

A: You can perform the following steps to view the fees:
  1. Log on to the ApsaraDB for MongoDB console. In the top navigation bar, choose Expenses > User Center. User center
  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

OperationDescription
DescribeBackupPolicyQueries the backup policy of an instance.
ModifyBackupPolicyModifies the backup policy of an instance.