question

ShubhiJain-0841 avatar image
0 Votes"
ShubhiJain-0841 asked OuryBa-MSFT commented

How to do multiple database backup and restore using sqlpackage.exe

I have more than 200 databases and I want to migrate it from on-premises SQL Server to Azure SQL Database using sqlpackage.exe.

"sqlpackage.exe /a:Export /ssn: /sdn: /su: /sp: /tf:"

this is the command I am using for creating bacpac file of database in on-premises

"sqlpackage.exe /a:Import /sf: /tsn: /tdn: /su: /sp:"

this is the command I am using for migrating the data to Azure SQL Database

But how I can use this in loop or something similar so that I won't have to Manually enter the database name.

azure-sql-databasesql-server-migration
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ShubhiJain-0841 Did you have the chance to try the script below shared by Criszhan-msft. Please let us know if you need further assistance.
Best Regards,
Oury

0 Votes 0 ·

1 Answer

Criszhan-msft avatar image
0 Votes"
Criszhan-msft answered

Hi,

Please refer to the PowerShell Script provided in this blog.
https://techcommunity.microsoft.com/t5/azure-database-support-blog/lesson-learned-32-how-to-export-multiple-databases-from-sql/ba-p/369017


Select Name from sys.databases Where database_id>=5 and name <>'distribution' Order by Name

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.