Home
%3CLINGO-SUB%20id%3D%22lingo-sub-803830%22%20slang%3D%22en-US%22%3EBackup%20Azure%20Database%20for%20MySQL%20to%20a%20Blob%20Storage%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-803830%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22lia-message-subject-wrapper%20lia-component-subject%20lia-component-message-view-widget-subject-with-options%22%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EOften%20customers%20want%20to%20backup%20Azure%20Database%20for%20MySQL%20to%20a%20Blob%20storage.%26nbsp%3B%3CSTRONG%3E%3CEM%3Emysqldump%3C%2FEM%3E%3C%2FSTRONG%3Eutility%20can't%20directly%20write%20the%20output%20file%20on%20a%20Blob%20Storage%2C%20in%20this%20post%20I%20will%20explain%20how%20this%20can%20be%20done%20using%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Ffiles%2Fstorage-files-introduction%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Files%3C%2FA%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%20class%3D%22lia-message-body-wrapper%20lia-component-message-view-widget-body%22%3E%0A%3CDIV%20id%3D%22bodyDisplay%22%20class%3D%22lia-message-body%22%3E%0A%3CDIV%20class%3D%22lia-message-body-content%22%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1-%20Navigate%20to%20your%20Azure%20Database%20for%20MySQL%20server%20on%20the%20portal%20and%20Run%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcloud-shell%2Fquickstart%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Cloud%20Shell%20(Bash).%26nbsp%3B%26nbsp%3B%3C%2FA%3EIf%20you%20run%20this%20for%20the%20first%20time%20it%20will%20ask%20you%20to%20create%20a%20Storage%20container%20and%20and%20this%20will%20mount%20an%20Azure%20File%20in%20it.%3C%2FP%3E%0A%3CP%3E2-%20Type%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CEM%3Edf%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Ein%20the%20cloud%20shell%20and%20collect%20the%20Azure%20File%20path%3C%2FP%3E%0A%3CP%3E3-%20Change%20directory%20to%20the%20cloud%20drive%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CEM%3Ecd%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Ecommand%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bin%20the%20example%20below%20I%20used%26nbsp%3B%3CEM%3Ecd%20%2Fusr%2Fbashar%2Fclouddrive%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E4-%20Now%20that%20you%20are%20in%20that%20directory%20run%20%3CEM%3E%3CSTRONG%3Emysql%3C%2FSTRONG%3E%3C%2FEM%3Ecommand%20to%20extract%20the%20backup%20dump%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126900iD2341C1F0130B9FC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MySQLdump.jpg%22%20title%3D%22MySQLdump.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E5-%20Backup%20file%20is%20ready%20and%20in%20this%20example%20it%20is%20under%20File%20System%20%22%3CEM%3Ecs47e4f0dddd931x4619xbf7%3C%2FEM%3E%22%2C%20navigate%20on%20the%20Azure%20Portal%20to%20that%20file%20system%2C%20as%20in%20the%20following%20screenshot.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126901i8A1B72792DC35CC8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22file%20system.jpg%22%20title%3D%22file%20system.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E6-%20Download%20backup%20file%20if%20needed%20or%20alternatively%20move%20it%20to%20Blob%20Storage%20using%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Fcommon%2Fstorage-use-azcopy-v10%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzCopy%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FA%3Eutility%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126902i7CEC0638707D35DE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MySQLbackup.jpg%22%20title%3D%22MySQLbackup.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-856279%22%20slang%3D%22en-US%22%3ERe%3A%20Backup%20Azure%20Database%20for%20MySQL%20to%20a%20Blob%20Storage%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-856279%22%20slang%3D%22en-US%22%3E%3CH1%20id%3D%22toc-hId-2012966717%22%20id%3D%22toc-hId-2012966717%22%3E%3CSTRONG%3EBackup%20Azure%20Database%20for%20MySQL%3C%2FSTRONG%3E%3C%2FH1%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E---%20backup%20single%20database%3A%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CEM%3Emysqldump%20-Fc%20-v%20-h%20XXXXXXX.mysql.database.azure.com%20-u%20XXXXXXX%20-p%20-d%20databaseName1%20%26gt%3B%20databaseName1_backup.sql%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%3CSTRONG%3E---%20backup%20multiple%20database%3A%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3Emysqldump%20-Fc%20-v%20-h%20XXXXXXX.mysql.database.azure.com%20-u%20XXXXXXX%20-p%26nbsp%3B%20--databases%20db1%20db2%20db3%26nbsp%3B%20%26gt%3B%20databases-backup.sql%3CBR%20%2F%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSTRONG%3E---%20backup%20all%20databases%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CEM%3Emysqldump%20-Fc%20-v%20-h%20XXXXXXX.mysql.database.azure.com%20-u%20XXXXXXX%20-p%20--all-databases%20%26gt%3B%20all_databases_backup.sql%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EIf%20you%20see%20issue%20%22mysqldump%3A%201044%20Access%20denied%20when%20using%20LOCK%20TABLES%22%20Or%3CBR%20%2F%3E%22Access%20denied%20for%20use%20'%40'%25'%20to%20database%20'mysql'%20when%20using%20LOCK%20TABLES%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%20quick%20workaround%20is%20to%20pass%20the%20%E2%80%93-single-transaction%20option%20to%20mysqldump%3A%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CEM%3Emysqldump%20-Fc%20-v%20-h%20XXXXXXX.mysql.database.azure.com%20-u%20XXXXXXX%20-p%20--single-transaction%20--all-databases%20%26gt%3B%20all_databases_backup.sql%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3Eref%3A%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2F%3C%2FA%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft
Often customers want to backup Azure Database for MySQL to a Blob storage. mysqldump utility can't directly write the output file on a Blob Storage, in this post I will explain how this can be done using Azure Files.

 

1- Navigate to your Azure Database for MySQL server on the portal and Run Azure Cloud Shell (Bash).  If you run this for the first time it will ask you to create a Storage container and and this will mount an Azure File in it.

2- Type df in the cloud shell and collect the Azure File path

3- Change directory to the cloud drive using the cd command
     in the example below I used cd /usr/bashar/clouddrive

4- Now that you are in that directory run mysql command to extract the backup dump

MySQLdump.jpg

5- Backup file is ready and in this example it is under File System "cs47e4f0dddd931x4619xbf7", navigate on the Azure Portal to that file system, as in the following screenshot.

file system.jpg

6- Download backup file if needed or alternatively move it to Blob Storage using AzCopy utility

MySQLbackup.jpg

1 Comment
Occasional Visitor

Backup Azure Database for MySQL

 

--- backup single database:
mysqldump -Fc -v -h XXXXXXX.mysql.database.azure.com -u XXXXXXX -p -d databaseName1 > databaseName1_backup.sql

 

--- backup multiple database:

mysqldump -Fc -v -h XXXXXXX.mysql.database.azure.com -u XXXXXXX -p  --databases db1 db2 db3  > databases-backup.sql


--- backup all databases


mysqldump -Fc -v -h XXXXXXX.mysql.database.azure.com -u XXXXXXX -p --all-databases > all_databases_backup.sql


If you see issue "mysqldump: 1044 Access denied when using LOCK TABLES" Or
"Access denied for use '@'%' to database 'mysql' when using LOCK TABLES"

 

A quick workaround is to pass the –-single-transaction option to mysqldump:


mysqldump -Fc -v -h XXXXXXX.mysql.database.azure.com -u XXXXXXX -p --single-transaction --all-databases > all_databases_backup.sql

 

 

ref:

https://docs.microsoft.com/en-us/azure/mysql/