All Products
Search
Document Center

ApsaraDB RDS:How do I use get_rds_backup.py to download the backup files of an ApsaraDB RDS for MySQL instance?

Last Updated:Jan 26, 2024

This topic describes how to use get_rds_backup.py to download the backup files of an ApsaraDB RDS for MySQL instance to your on-premises server. You can specify a time range for a download. By default, the backup files that are generated on and before the previous day are downloaded.

Take note of the following items:

  • Before you perform high-risk operations such as modifying the configurations or data of your instances, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.

  • Before you modify the configurations or data of an instance, such as an Elastic Compute Service (ECS) instance or an ApsaraDB RDS instance, we recommend that you create snapshots or enable backup for the instance. For example, you can enable log backup for an ApsaraDB RDS instance.

  • If you have granted permissions on sensitive information or submitted sensitive information in the Alibaba Cloud Management Console, we recommend that you modify the sensitive information at the earliest opportunity. Sensitive information includes usernames and passwords.

Prerequisites

  • The RDS instance uses local disks. Cloud disks are not supported.

  • The method that is described in this topic is supported in Linux, Windows, and operating systems that support the Python 2.7 runtime environment.

Billing rules

You are charged for downloading the backup files of an RDS instance by using get_rds_backup.py. For more information about billable items and billing rules, see Download backup files.

Procedure

  1. Install the Python 2.7 runtime environment and ApsaraDB RDS SDK for Python on your on-premises server. For more information, see Install and use ApsaraDB RDS SDK for Python.

    1. Run the following command in Python to install the core library of Alibaba Cloud SDK:

      pip install aliyun-python-sdk-core
    2. Run the following command to install ApsaraDB RDS SDK for Python:

      After ApsaraDB RDS SDK for Python is installed, you can use it to perform operations on your RDS instance and manage your RDS instance.

      pip install aliyun-python-sdk-rds
  2. Make sure that your on-premises server can be connected to an RDS instance by using the public endpoint of the RDS instance.

    Note
  3. Download the get_rds_backup.py script file to your on-premises server.

    Note

    After you download the script file, you need to specify the following information in the script file based on your business requirements: the ID of the RDS instance, AccessKey ID and AccessKey secret of your RAM user, and the directory in which you want to store the backup files of the RDS instance.

  4. Run the following command to execute the get_rds_backup.py script file:

    python get_rds_backup.py [$RDS_ID] [$Access_Key_ID] [$Access_Key_Secret] [$Backup_Dir]
    Note
    • [$RDS_ID]: the ID of the RDS instance. You can view the ID on the Basic Information page of the RDS instance. Example: rm-rm-hp38****2i07.

    • [$Access_Key_ID]: the AccessKey ID of the RAM user. If no RAM users are created, you can create one. For more information, see Create a RAM user.

    • [$Access_Key_Secret]: the AccessKey secret of the RAM user.

    • [$Backup_Dir]: the directory in which you want to store backup files. Make sure that the disk space is sufficient. Otherwise, the download may fail.

    • By default, the data backup files that are generated on and before the previous day are downloaded. To change the time range, you can change the values of the starttime and endtime variables in the script file.

    The following figure shows an sample output. 返回

References

Download backup files

Applicable scope

ApsaraDB RDS for MySQL