All Products
Search
Document Center

ApsaraDB for MongoDB:Configure automatic backup for an ApsaraDB for MongoDB instance

Last Updated:Feb 06, 2024

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

Prerequisites

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

Usage notes

  • If the database engine version of your instance is earlier than MongoDB 4.0 and the physical backup method is used, physical backups may fail when the total number of collections and indexes in the instance exceeds 10,000. Before a physical backup task is executed, you can upgrade the database engine version of your instance to MongoDB 4.0 or later. For more information, 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.

  • The single-digit second backup feature can be enabled only for ApsaraDB for MongoDB replica set instances that run MongoDB 4.4 or later.

  • The log backup feature can be enabled only for replica set instances and sharded cluster instances.

  • The retention period of log backups cannot be longer than the retention period of full backups.

  • After the log backup feature is disabled, 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.

Instance architecture

Backup method

Description

  • Standalone instances

  • Replica set instances that use cloud disks

  • Sharded cluster instances that use cloud disks

Snapshot backup

Snapshot 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 instances that use local disks

  • Sharded cluster instances that use local disks

Physical backup

Physical backup stores the 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 number 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 backup storage, you are charged backup fees on an hourly basis. The backup fees are calculated based on the following formula: Backup fees per hour = (Backup storage - Free quota) × Unit price for backup files.

The following table describes the billing details.

Storage type

Free quota

View the backup storage and free quota

Instance that uses cloud disks

The free quota is equal to 200% of the storage capacity that you purchase for your instance.

You can view the backup storage and free quota in the Specification Information section of the Basic Information page of your instance.

Instance that uses local disks

The free quota is equal to 50% of the storage capacity that you purchase for your instance.

The following table describes the billing details of the excess backup storage.

Storage type

Unit price of backup (USD per GB-day)

Instance that uses cloud disks

0.00096

Instance that uses local disks

0.0048

For more information, go to the Pricing tab of the ApsaraDB for MongoDB product page.

Warning

The preceding unit price of backup is for reference only. The unit price may change when you purchase an instance. The unit price generated in purchase inquiries and bills prevails.

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.

  3. In the upper-left corner of the page that appears, select the resource group and region to which the desired instance belongs.

  4. Click the ID of the instance or click Manage in the Actions column.

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

  6. On the Full Backup tab, configure a backup policy.

    1. Click Backup Settings.

    2. In the Backup Settings panel, configure the parameters described in the following table.

      Parameter

      Description

      Backup Method

      Select Standard Backup or High-frequency Backup.

      In this example, parameters related to Standard Backup are configured. For more information about parameters related to High-frequency Backup, see High-frequency backup.

      Full Backup Retention Period (Days)

      The retention period of full backups. Valid values: 7 to 730. Unit: day.

      Note

      By default, this parameter is set to 30 for instances that are purchased after September 10, 2021.

      Backup Within Seconds

      Specifies whether to turn on Backup Within Seconds. By default, the single-digit second backup feature is disabled.

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

      Note

      Single-digit second backup is available only for ApsaraDB for MongoDB replica set instances that run MongoDB 4.4 or later.

      Backup Time

      The period of time during which you want backup tasks to be performed.

      We recommend that you 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 Week

      The frequency at which data is backed up. Data is backed up seven times per week by default.

      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 Backup

      Specifies whether to turn on Log Backup. By default, the log backup feature is enabled.

      • After the log backup feature is enabled, 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 backup logs and click the Log Backup tab to view the details of backup logs.

        • The log backup feature can be enabled only for replica set instances and sharded cluster instances.

      • After you disable the log backup feature, 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 backups that were 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 turn on Log Backup.

        Important

        After the log backup feature is disabled, log backups are deleted and cannot be restored.

      Log Backup Retention Period (Days)

      If you turn on Log Backup, you must specify the retention period of log backups. Valid values: 7 to 730. Default value: 7. Unit: day.

      Note

      The retention period of log backups cannot be longer than the retention period of full backups.

    3. Click OK.

FAQ

How do I view the fees incurred for instance backup?

You can view the bills of the Backup Storage Size billable item on the Billing Details tab of the Bill Details page.

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.