Azure Database for MySQL - Flexible Server is a fully managed open-source community database service that offers multiple options for high-availability, maintenance control, and a simplified, out-of-the-box experience. With exciting new features released each month, be sure to consider migrating to Flexible Server so that you can quickly leverage its benefits!
To migrate from Azure Database for MySQL – Single Server to Flexible Server, you can use any of a variety of methods. Generally, migrations are classified either as offline, or online (minimal downtime). For offline migrations, you can use utilities such as Azure Database Migration Service, MySQL Workbench, mydumper/myloader, or mysqldump to backup and restore the database. For online migrations with minimal downtime, you can use the same utilities in combination with Data-in replication.
However, migration isn't just about moving your schema and data. The process also involves some post-migration tasks, such as data validation and migration of security settings such as firewall rules and server parameter configurations. This is important to ensuring that your application actually functions properly. This task can at times prove tedious, especially when you’re dealing with a large of fleet of servers with multiple databases.
In this post, you learn how to use a sample shell script to automate migration tasks with the mysqldump utility. The script enables you to easily automate migration of single servers containing multiple databases in 5 easy steps, as shared below. The sample script migrates:
You can also use the script to create a basic database migration validation report after the migration completes.
Note:
Important: We recommend that you test the script thoroughly before using it in a production environment.
Before you begin, be sure that you have:
Also be sure to consider the following points.
wget -L https://raw.githubusercontent.com/Azure/azure-mysql/master/azuremysqltomysqlmigrate/azuremysqlmigfinal.sh
wget -L https://raw.githubusercontent.com/Azure/azure-mysql/master/azuremysqltomysqlmigrate/migrateparameter.json
3. Edit the parameter file migrateparameter.json or create a parameter file (using the contents of master parameter file as a template) to provide details of the migration.
Tip: If you're working with the cloud shell and want to edit the file, use the in-house editor by selecting the { } icon in the shell.
4. To make the script executable, run the following command:
chmod +x azuremysqlmigfinal.sh
5. To use the script, run the following command:
./azuremysqlmigfinal.sh Parameterfilename
Note:
For more details and for the latest version of the script, please visit our GitHub repo.
After you’ve updated the parameter file, run the script to:
If connectivity fails, the script exits.
The log file and the validation report are included in the same folder:
The validation report helps by:
If there's an error, the report provides a query that you can use to determine the cause of the validation failure.
Tip: You can run the command cat validation_reportmmddyyHHMMSS.txt | grep "Error:" to filter the error from the report.
With the information above, you should easily be able to migrate your databases from Azure Database for MySQL - Single Server to Flexible Server.
The script shared as part of this post is not a managed solution and is therefore unsupported by Microsoft Customer Support and Services (CSS). The solution is open-source and maintained by the community of experts in GitHub. For any issues, we recommend that you open an issue in GitHub. Also, feel free to contribute any updates or bug fixes by creating a pull request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.