All Products
Search
Document Center

Use DBS to back up a MongoDB database

Last Updated: Jul 28, 2020

Database Backup (DBS) supports backup and recovery for MongoDB instances and provides the features of single-table restoration, remote backup, full data backup, incremental backup, and long-term archiving.

Features

Feature Description
SQL file backup DBS uses the logical backup technology to store backup data in JSON files.
Backup data query DBS allows you to use SQL statements to query backup sets without restoring data. For more information, see Use SQL statements to query backup sets.
Remote backup DBS supports backing up a MongoDB instance to an Object Storage Service (OSS) bucket in the destination region. It also supports restoring the backup data to a MongoDB instance in the destination region, source region, or any other regions.
Long-term archiving DBS supports retaining backup files for up to five years, after which the backup set will be automatically transferred to Archive Storage.
Fine-grained backup DBS supports backing up a single table, a single database, multiple databases, or an entire MongoDB instance.
Backup speed limit DBS allows you to limit the backup speed to significantly reduce the negative impact of backup operations on the performance of the database.
Single-table restore DBS supports restoring a single table without restoring the entire MongoDB instance. This reduces the time required for data restore.

Create a backup schedule

  1. Log on to the DBS console.

  2. Click Create Schedule in the upper-right corner to go to the DBS buy page.

  3. Set the parameters as described in the following table and click Buy Now.

    Section Parameter Description
    Basic DBS Region The region where the DBS instance to be purchased resides.
    Make sure that the selected region is the same as the region where you want to store the backup data.
    Database Type The type of the database to be backed up. In this example, select MongoDB.
    Specification The type of the DBS instance to be purchased. For more information, see How to select DBS instances.
    Backup Method The method used to back up the ApsaraDB RDS for PostgreSQL instance. Currently, only logical backup is supported for ApsaraDB RDS for PostgreSQL instances.
    Storage Size The storage size of the DBS instance to be purchased. You do not need to specify the storage size when you purchase a DBS instance. The instance is charged in the pay-as-you-go mode. You can also purchase a storage package. A favorable discount is available if you purchase a large storage package.
    Purchase Plan Quantity The number of DBS instances to be purchased. Set this parameter based on your actual needs.
    Duration The validity period of the purchased DBS instance. Set this parameter based on your actual needs.
  4. On the Confirm Order page, confirm your order information, read and accept the DBS (Subscription) Agreement of Service, and then click Pay.

  5. After you pay for the order, log on to the DBS console and click Backup Schedules in the left-side navigation pane to view the new backup schedule.

Configure the backup schedule

  1. Log on to the DBS console.

  2. In the left-side navigation pane, click Backup Schedules.

  3. On the Backup Schedules page, find the target backup schedule and click Configure Backup Schedule in the Actions column.
    Backup schedules MongoDB

  4. In the Configure Backup Source and Destination step, configure the backup source and destination.

    Section Parameter Description
    None Schedule Name The name of the backup schedule. DBS automatically generates a schedule name. We recommend that you specify an informative name for easy identification. You do not need to use a unique schedule name.
    Backup Source Information Backup Mode The method used to back up the ApsaraDB RDS for PostgreSQL instance. Currently, only logical backup is supported for ApsaraDB RDS for PostgreSQL instances.
    Database Location The location of the database to be backed up. Valid values:
    • User-Created Database with Public IP Address
    • ECS-Hosted Database
    • ApsaraDB for MongoDB
    • Express Connect DB/VPN Gateway/Intelligent Gateway
    • No public network IP: Port’s self-built database (accessed through the database gateway)
    Database Type The type of the database to be backed up. In this example, this parameter is set to MongoDB.
    If you set Database Location to ApsaraDB for MongoDB, this parameter is unavailable.
    Instance Region The region where the database to be backed up resides.
    This parameter is available only when you set Database Location to ECS-Hosted Database, ApsaraDB for MongoDB, or No public network IP: Port’s self-built database (accessed through the database gateway).
    Address The public endpoint used to connect to the database to be backed up.
    This parameter is available only when you set Database Location to User-Created Database with Public IP Address , Express Connect DB/VPN Gateway/Intelligent Gateway, or No public network IP: Port’s self-built database (accessed through the database gateway).
    Port Number The port used to connect to the database to be backed up.
    If you set Database Location to ApsaraDB for MongoDB, this parameter is unavailable.
    ECS Instance ID The ID of the ECS instance where the database to be backed up resides.
    This parameter is available only when you set Database Location to ECS-Hosted Database.
    MongoDB Instance ID The ID of the ApsaraDB for MongoDB instance to be backed up.
    This parameter is available only when you set Database Location to ApsaraDB for MongoDB.
    Peer VPC The virtual private cloud (VPC) where the database to be backed up resides.
    This parameter is available only when you set Database Location to Express Connect DB/VPN Gateway/Intelligent Gateway.
    Database gateway instance ID The ID of the database gateway instance.
    This parameter is available only when you set Database Location to No public network IP: Port’s self-built database (accessed through the database gateway).
    Database Name The name of the database to be backed up.
    Database Account The username of the account used to connect to the database to be backed up.
    Password The password of the account used to connect to the database to be backed up.
    After you enter the database account and password, click Test Connection next to Password to check whether the information about the database to be backed up is correct. If the specified parameters are valid, the Test Passed message appears. If the Test Failed message appears, click Check next to Test Failed. Modify the information about the database to be backed up based on the check results.
    Backup Destination Information Backup Storage Type The type of the storage used to store backup data. Valid values:
    • DBS built-in storage
    • OSS for user
    OSS Bucket Name The name of the OSS bucket.
    This parameter is available only when you set Backup Storage Type to OSS for user.
    Storage Encryption The method used to encrypt the stored data. Valid values:
    • Non-encrypted
    • Encrypted
    • KMS Encrypted

    configure backup schedule MongoDB

  5. In the lower-right corner of the page, click Next.

  6. In the Edit Backup Objects step, find the database or table to be backed up in the Available section, click the rightwards arrow to add the selected database or table to the Selected section, and then click Next.

    If you back up an entire database, permission data and stored procedures will also be backed up.

  7. In the Configure Backup Time step, set the parameters as described in the following table and click Next.

    Parameter Description
    Full-scale Backup Frequency The frequency of the backup schedule. Valid values: Periodic Backup and Single Backup.
    Full Data Backup Recurrence The day in a week on which DBS runs the backup schedule.
    Full Data Backup Start At The start time of the backup.
    If the time taken for a full data backup is longer than the backup interval, DBS skips the next backup.
    Real-Time Transaction Log Backup Specifies whether to enable incremental backup.
    Before you enable incremental backup, you must enable the replica set feature in the database instance and grant the user the permission to read data from the local database. This feature is enabled by default in multi-node ApsaraDB for MongoDB instances.
    Maximum Concurrent Threads for Full Data Backup The maximum number of concurrent threads available for a full data backup.
    The value varies with the specifications of the DBS instance that you purchased when you created the backup schedule.
  8. In the Edit Lifecycle step, configure the lifecycle for a full data backup in the Configure Full Data Backup Lifecycle section.

  9. After the configuration is complete, click Precheck in the lower-right corner of the page.

  10. If the Precheck Passed message appears, click Start Task.
    Precheck MongoDB

  11. When the status of the backup schedule changes to Running, the backup schedule takes effect.

View the backup schedule

  1. Log on to the DBS console.
  2. In the left-side navigation pane, click Backup Schedules.
  3. On the Backup Schedules page, find the target backup schedule and click Manage in the Actions column.
  4. On the Configure Task page, view the basic information and running status of the backup schedule.
  5. In the left-side navigation pane, choose Backup Tasks > Full Data to view information about all full data backups.
    Full data MongoDB

Restore a MongoDB instance

  1. Log on to the DBS console.
  2. In the left-side navigation pane, click Backup Schedules.
  3. On the Backup Schedules page, find the target backup schedule and click Manage in the Actions column.
  4. On the Configure Task page, click Restore Database in the upper-right corner.
  5. In the Set Time Restored To step in the Create Restore Task wizard, set the parameters as described in the following table and click Next.

    Section Parameter Description
    None Task Name The name of the restore task. DBS automatically generates a task name. We recommend that you specify an informative name for easy identification. You do not need to use a unique task name.
    Set Time Restored To Time Range Available to Restore The time range available for restoring backup sets. DBS displays the available time range automatically.
    Restore To The time point that you want to restore the source database to. The value must be within the time range specified by Time Range Available to Restore.
    Configure Destination Database Database Location The location of the database to be restored. Valid values:
    • User-Created Database with Public IP Address
    • ECS-Hosted Database
    • ApsaraDB for MongoDB
    • Express Connect DB/VPN Gateway/Intelligent Gateway
    • No public network IP: Port’s self-built database (accessed through the database gateway)
    Database Type The type of the database to be restored. In this example, this parameter is set to MongoDB.
    If you set Database Location to ApsaraDB for MongoDB, this parameter is unavailable.
    Instance Region The region where the database to be restored resides.
    This parameter is available only when you set Database Location to ECS-Hosted Database, ApsaraDB for MongoDB, or No public network IP: Port’s self-built database (accessed through the database gateway).
    Address The public endpoint used to connect to the database to be restored.
    This parameter is available only when you set Database Location to User-Created Database with Public IP Address , Express Connect DB/VPN Gateway/Intelligent Gateway, or No public network IP: Port’s self-built database (accessed through the database gateway).
    Port Number The port used to connect to the database to be restored.
    If you set Database Location to ApsaraDB for MongoDB, this parameter is unavailable.
    ECS Instance ID The ID of the ECS instance where the database to be restored resides.
    This parameter is available only when you set Database Location to ECS-Hosted Database.
    MongoDB Instance ID The ID of the ApsaraDB for MongoDB instance to be restored.
    This parameter is available only when you set Database Location to ApsaraDB for MongoDB.
    Peer VPC The virtual private cloud (VPC) where the database to be restored resides.
    This parameter is available only when you set Database Location to Express Connect DB/VPN Gateway/Intelligent Gateway.
    Database gateway instance ID The ID of the database gateway instance.
    This parameter is available only when you set Database Location to No public network IP: Port’s self-built database (accessed through the database gateway).
    Database Name The name of the database to be restored.
    Database Account The username of the account used to connect to the database to be restored.
    Password The password of the account used to connect to the database to be restored.
    After you enter the database account and password, click Test Connection next to Password to check whether the information about the database to be restored is correct. If the specified parameters are valid, the Test Passed message appears. If the Test Failed message appears, click Check next to Test Failed. Modify the information about the database to be restored based on the check results.
    Create Restore Task MongoDB

  6. In the Configure Objects to Restore step in the Create Restore Task wizard, set the parameters as described in the following table and click Precheck.

    Parameter Description
    Conflict Handling The method used to handle a name conflict. Valid values: Fail When Object with the Same Name Exists and Rename Object with the Same Name.
    If you select Rename Object with the Same Name, DBS renames the object in the following manner: For example, if the table named job_info already exists, DBS automatically renames the new table as job_info_dbs_<Restore task ID>_</Timestamp> by default.
    Objects to Restore The database or table to be restored. Select the database or table to restore in the Available section and click the rightwards arrow to add it to the Selected section.
  7. If the Precheck Passed message appears, click Start Task.