How to Restore Files and Folders From Azure Linux VM using #AzureBackup #Linux #Azure @AzureBackup

4 min read

Instant File Recovery from Azure VM – image credit: Microsoft


Azure Backup is the Azure based service you can use to backup and restore your data in Microsoft Azure Cloud Platform. Azure Backup replaces your existing on-premises or off-site backup solution with a cloud-based solution that is reliable, secure, and cost-effective. Please check the following article for the complete overview of the features in Azure Backup.

Earlier this year, Microsoft announced the preview of File and Folder Recovery from Azure Linux VM and Azure Windows VM backups. Last month, Microsoft announced the generally availability (GA) of this service. You can read all about here.

In this blog post, I will show you how to restore files and folders from Azure Linux VM using Azure Backup.

Getting ready

You need to have a Linux VM deployed in Azure with Azure Backup enabled. Please check the following post to learn more about how to enable back up for Azure virtual machines.

You need to have Linux machine running on-premises to recover Files and Folders and vice versa for Azure Windows VM as well. This is very important, more on that on How it works… section.

You need to ensure that the OS of the recovery Linux machine on-premises is compatible with the backed up VM in Azure. The supported versions are as follows:

  • Ubuntu – V12.04 and above
  • CentOS – V6.5 and above
  • RHEL – V6.7 and above
  • Debian – V7 and above
  • Oracle Linux – V6.4 and above

How to do it…

Assuming you have all the prerequisites in place. Now take the following steps:

    1. Login to Azure portal.
    2. Browse to Virtual machines blade and select the Linux VM that you want to recover from.
    3. Click on Backup under SETTINGS, and then click on File Recovery.
    4. The File Recovery blade will open as shown in the next screenshot. Select which recovery point you want to recover from the drop-down list.
    5. Click on “Download Script *” and then save it on your local machine.
    6. You need to copy this script to your Linux machine running on-premises. There are certain ways to do that. In this example, I will use WinSCP a free tool for SFTP, SCP and FTP client for Windows.
    7. Connect using WinSCP to your Linux machine and then copy the script to your home directory.
    8. Login to your Linux machine and Open Terminal window.
    9. Type: sudo bash and enter your credentials.
    10. Type: chmod +x followed by the script file name as shown in the next screenshot.
    11. chmod is the command and system call which may change the access permissions to file system objects (files and directories). The mode +x will apply execute permissions to the file that we just copied.
    12. Type: bash followed by the script file name as shown in the next screenshot. The script requires administrative privilege to run.
    13. Microsoft Azure VM Backup – File Recovery will launch. Enter the password as shown on the portal. The connection will succeed and the mount path for the attached volume will be displayed as shown in below screenshot.
    14. Enter ‘q‘ or ‘Q‘ to exit.
    15. You can simply browse to the relevant mount path by typing cd followed by the MountPath. After that you can list the file system and see all the files and folders.
    16. Finally, you can copy the desired file and folder to your local machine by running the following command: cp -a /SourcePath/ . /DestinationPath/

The “-a” option is an improved recursive option, that preserve all file attributes, and also preserve symlinks. The “.” at end of the source path is a specific “cp” syntax that allow to copy all files and folders, included hidden ones.

How it works…

When you click on File Recovery, you need to select which recovery point you want to recover, the latest recovery point is selected by default. Next, you need to download a script. The script and password will be generated instantly. You will require this password to run the script.

What this script do is, when you are trying to do a file or folder recovery for the first time, the script will open an iSCSI and LSHW component to be installed on the Linux machine to connect to the recovery point. The script has a time bomb in it and it is valid only for 6 hours, after that the script is not valid anymore, and you have to download it again. This is very important for security reasons.

As mentioned earlier in this post, the script should be run on a Linux machine because this is a Linux VM that you are trying to mount, it will expose that iSCSI device, it does NOT download everything from the cloud, and then it will mount the iSCSI device to your local machine. The script is a shell script with .sh extension.

After running the script, you are required to enter a password generated automatically from the portal specifically for that script. The iSCSI device will be mounted into your file system, and that mount will be valid only for 12 hours, after that it will automatically disconnect that mount point. You can also click “Unmount Disks” in Step 3 of the portal once the recovery is done. The connection will be closed to the recovery point.

That’s all there is to it.

[email protected]

About Charbel Nemnom 559 Articles
Charbel Nemnom is a Cloud Architect, ICT Security Expert, Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT), totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 17 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems. Excellent communicator is adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design, business continuity, and cloud security.

Be the first to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.