
Recently I migrated some Linux Systems with Azure Migrate from a VMWare environment to Azure. We also used Azure Backup to have a daily backup of all VMs and of all Databases as well, but we had not application consistent one. I needed some troubleshooting time to figure out how it works. This step by step guide shows an example how I did it and how to prepare a test environment. This includes how to installs MySQL, creating a Database and how to configure Azure Backup to have an app consistent Backup.
- Install MySQL
- Create a Database
- Configure Azure Backup
Install MySQL
Prerequisites
To follow this guide you need to use (because I did 😉 ):
– Ubuntu 20.04
$ sysop@linux01:/$ sudo apt update
output:

$ sysop@linux01:/$ sudo apt install mysql-server
$ systemctl status mysql.service
output:

$ sudo mysql
mysql> create database techguysdb;
mysql> show databases;
output:

Configure Azure Backup
To configure Azure Backup you need to do the following:
- Download and prepare VMSnapshotPluginConfig.json
- prepare pre and post script
- enable Azure Backup for your Linux VM
- shutdown Linux VM and do a backup
- start Machine and do a second backup
VMSnapshotPluginConfig
I followed the Microsoft documentation https://docs.microsoft.com/en-us/azure/backup/backup-azure-linux-app-consistent
First we need to download the VMSnapshotPluginConfig.json file here: https://github.com/MicrosoftAzureBackup/VMSnapshotPluginConfig.
{
“pluginName” : “ScriptRunner”,
“preScriptLocation” : “”,
“postScriptLocation” : “”,
“preScriptParams” : [“”, “”],
“postScriptParams” : [“”, “”],
“preScriptNoOfRetries” : 0,
“postScriptNoOfRetries” : 0,
“timeoutInSeconds” : 30,
“continueBackupOnFailure” : true,
“fsFreezeEnabled” : true
}
This file contains different values that need to be changed to fit to the current environment. My file look like this:
{
“pluginName” : “ScriptRunner”,
“preScriptLocation” : “/scripts/pre.sh”,
“postScriptLocation” : “/scripts/post.sh”,
“preScriptParams” : [“”, “”],
“postScriptParams” : [“”, “”],
“preScriptNoOfRetries” : 2,
“postScriptNoOfRetries” : 2,
“timeoutInSeconds” : 30,
“continueBackupOnFailure” : false,
“fsFreezeEnabled” : true
}
I changed “script location” and “continueBackupOnFailure” (this change helped me to see an error message within azure backup jobs, if one script fails)
VMSnapshotPluginConfig.json need to be copied to “/etc/azure”. If this do not exit, simply create. After that we need to change the permission to that file that only “root” has read and write permissions.
sysop@linux01:/etc/azure$ sudo chmod 600 VMSnapshotPluginConfig.json
Output of ls -l:

Pre and PostScript
To have a pre and a post script I used the examples from veeam https://bp.veeam.com/vbr/VBP/4_Operations/O_Application/mysql.html
my pre-script looks like this:

my post script looks like this:

both scripts must be copied to the Linux system. I copied it to /scripts. Next important task is to set permissions to 600 to both files otherwise azure backup will fail.sysop@linux01:/scripts$ sudo chmod 600 pre.sh
sysop@linux01:/scripts$ sudo chmod 600 post.sh

Backup
enable Backup for a Virtual Maschine


if the backup is enabled it looks like this. It is only configured but has never been executed. Restore points overview shows no backup.

1st Backup
Very important is that the first Backup needs to be done when the virtual machine is deallocated!

then run backup-job as configured

The Backup includes two steps. 1st take a snapshot, second is to copy data to the vault.

When the snapshot task is done the linux-system can be started and our vault shows a crash consistent backup

2nd backup
if the VM is up and running all scripts and config files are in place we can trigger the second backup. now the service should use all configuration and the result should be an app consistent backup 🙂
and here we go…

Hope that step by step guide helps to get this working.
Leave a Reply