Post

Automatic Database Backup Of Golden Configuration Environment D365FO

In this article, I will talk about automated database backup of Golden Configuration Environment or any tier 1 or 2 cloud-hosted environments.
we will be using Azure DevOps and Azure storage for this.

Prerequisites

  1. Must have an Azure DevOps organization
  2. Must have an Azure subscription with a storage account


blob diagram

In this article, we will assume that our environment is stopped and we have to start it and create a backup and then stop again.
In summary, we will be creating an Azure DevOps pipeline that will run every day(this can be hanged), start the virtual machine then run a PowerShell script in the VM which will create a backup and store it in an Azure blob.

Steps

  • Create a library on ADO (you can name it Database-Backup, we will be needing this name later), you can follow the official documentation
  • Add the following keys
    • AZBackupServiceConnection - Storage Account service connection name (follow Official docs)
    • AZVMServiceConnection - Virtual Machine resource group service connection name
    • BlobContainer - Blob container name
    • DatabaseName - Database name (AXDb)
    • InstanceName - Database Instance (DEFAULT)
    • StorageAccount - Storage account name (where the backup file will store)
    • StorageAccountResourceGroup - storage account resource group (where the backup file will store)
    • VMName - D365 virtual machine name
    • VMResourceGroup - D365 virtual machine resource group name
  • Create a new YAML file in your repository (for example pipeline-backup.yaml)
  • Copy the YAML (you can find the YAML on GitHub)
  • Create a PowerShell script file (database-backup.ps1, and copy the content from GitHub )
  • Check-In the code, if you are creating this please push the code into the repository.
  • Create a new pipeline on Azure DevOps (you can get more information on official documentation), while creating the pipeline select the YAML file you created.
  • Almost done, now you can run and test your pipeline (If you face any issues, please create a discussion on GitHub)
  • Now we will create a schedule, please note this can be done in two ways
    • Adding cron in the YAML, I personally don’t like this, each time I want to update the time I have to update the repository and raise a PR and then wait for approvals. you can follow the official docs for this.
    • Adding the cron on Azure DevOps pipeline settings (classic approach). To add a schedule please follow the official docs, Edit the pipeline, and then from top right menu click on trigger and create a schedule.
  • Done.

Conclusion

I hope that you are able to achieve the task. if you face any issues please raise a QA on GitHub.

If you are interested in terraforming, DevOps, Cloud (Azure, GCP, or AWS), or .Net, please follow me on Medium and subscribe for the latest updates.

Happy Coding,
Cheers ? Bis Bald

This post is licensed under CC BY 4.0 by the author.