Restore external .bak file to Azure Managed Instance

HSB 65 Reputation points
2023-07-07T19:21:08.57+00:00

We are in the process of setting up an Azure Managed Instance and are testing with it.

In our current process, we get a nightly .bak file from a 3rd party and we automate that and back it up to one of our SQL databases. We have a job in the SQL Server Agent that runs this daily for us.

What are the options/best practices to restore this database in Azure still using this 3rd party .bak file and to have it automated?

Azure SQL Database
{count} votes

Accepted answer
  1. RahulRandive 10,486 Reputation points Volunteer Moderator
    2023-07-08T12:32:00.03+00:00

    Hi @HSB

    Not sure about any third-party App but I believe you can achieve this within Azure.

    You can use a stored proc activity and run the restore command inside that.
    Something like this : https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/restore-sample-database-quickstart#restore-from-a-backup-file

    Or you can also automate that by creating a Managed Instance and Data Factory/Synapse

    You can use the below query in the Script activity of the Data factory

    RESTORE DATABASE [dbname] FROM URL = N'https://abcxxxxx.blob.core.windows.net/<>/dbname.bak'

    Please find the below screenshot (similar one), select Script Activity and use the linked service for the Managed Instance and place the .bak files in the Storage account and use that path in the query.

    User's image

    The .bak will be restored once the script activity is executed and that's how you can automate that process using Data Factory.

    Thank you!


1 additional answer

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-07-08T00:25:48.7133333+00:00

    My suggestion is to create a SQL Server Agent job that creates the backup on an Azure Storage account. Here you will find some good tricks to get the best performance with backups on Azure Managed Instance that I doubt a third party tool would consider.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.