Reputation: 576
We are using Azure devops to deploy changes to Azure SQL database using dacpac. I want to add a step in the build or release pipeline to take backup of the database but didn't find any task in devops marketplace. Can anyone suggest some way to take db backup in devops pipeline. It will be very helpful. Thanks.
Upvotes: 0
Views: 3664
Reputation: 3762
Through this Azure CLI command it is possible to view the backups, but it is not possible to create one! Only Microsoft does that periodically depending on your plan.
Though it is possible to create a complete copy of your database through this Azure CLI command like:
az sql db copy -g ResourceGroupName -s DbServerName -n DbName --dest-server DbBackupServerName --dest-name CopiedDbName --service-objective basic
You can use Azure Cli Task to run the command. Additionally in your pipeline you can set up a delay task and delete the new db later.
Upvotes: 0
Reputation: 28216
Azure CLI with az sql db commands can be used to manage your Azure Database. Azure Devops Service provides Azure CLI task to call Azure CLI in Azure Devops pipelins.
And here're two documents that you can refer to:
Use CLI to backup an Azure SQL single database to an Azure storage container
Use CLI to restore a single database in Azure SQL Database to an earlier point in time
Upvotes: 6