edit-icon download-icon

How to back up and roll back databases in ApsaraDB for RDS for MySQL

Last Updated: Jul 13, 2016
You can take two measures:
First, roll back the ApsaraDB for RDS instance database.
Second, back up the database of the temporary instance generated at the backup point and roll back to the ApsaraDB for RDS instance.
The first method: roll back the ApsaraDB for RDS instance database.
Step 1: Install MySQL Client on ECS (Linux)
1) Download MySQL Client
2) Install MySQL Client
Run: rpm -ivh MySQL-client-5.6.15-1.linux_glibc2.5.x86_64.rpm
Or you can use yum install mysql to install MySQL directly in the system.
Step 2: Back up the database of ApsaraDB for RDS instance
Run the command to complete database backup: mysqldump -h xxx.mysql.aliyun.com -u xxx -P 3306 -p --opt --default-character-set=utf8 --triggers --hex-blob db_name > /tmp/db_name.sql
After the password is entered, Mysqldump will carry out the backup and complete it automatically.
Check the SQL file generated at the backup, and run ll xx.sql.
Step 3: Roll back the ApsaraDB for RDS instance
Based on the backup file, roll back the ApsaraDB for RDS instance with the following commands
mysql -h xxxxxx.mysql.rds.aliyuncs.com -u user_name -P 3306 -p database_name
After the password is entered, the rollback operation will be completed automatically
The second method: back up the database of the temporary instance generated at the backup point and roll back to the ApsaraDB for RDS instance.
Step 1: Install MySQL Client on ECS (Linux)
1) Download MySQL Client
2) Install MySQL Client
Run: rpm -ivh MySQL-client-5.5.32-2.linux2.6.x86_64.rpm
Step 2: Create a temporary instance in Alibaba Cloud ApsaraDB for RDS console
Click the "Backup and Recovery" page on ApsaraDB for RDS console, select a backup set to create a temporary instance, as shown in the figure below
Each ApsaraDB for RDS instance can create a temporary instance. A temporary instance has read-only privilege. It inherits the account and password, as well as the Internet and intranet status at the backup point. After successful creation, the temporary instance is valid within 48 hours.
After successful creation of the temporary instance, we can see its information in the temporary instance list, such as: the connection string, port number, account name accessing the temporary instance (the accounts existing in the ApsaraDB for RDS instance when it is backed up), and the network types.
Step 3: Back up the database of MySQL for the child instance
Back up the database of the child instance with the following commands
mysqldump -h xxx.mysql.aliyun.com -u xxx -P 3306 -p --opt --default-character-set=utf8 --triggers --hex-blob db_name > /tmp/db_name.sql
After the password is entered, the backup of the child instance will be completed.
Note: Input the connection address, user name and database name of the child instance in the red frame in the above figure
Step 4: Roll back the ApsaraDB for RDS instance
Roll back the ApsaraDB for RDS instance with the following commands
mysql-h xxxxxx.mysql.rds.aliyuncs.com -u xxxx -P 3306 -p database_name
After the password is entered, the rollback operation of the ApsaraDB for RDS instance will be completed
Note: Input the connection address, user name and database name of the ApsaraDB for RDS instance in the red frame in the above figure
Thank you! We've received your feedback.