Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure SQL Database Bacpac Local Restore

I've created a BACPAC backup of my Azure SQL Database using the "Export" option within the Azure Management Console.

Having downloaded this to my machine I'm a little stuck on how I can restore this to a local SQL Server instance. I came across the DacImportExportCli tool but couldn't find an example of a local restore.

Also if anyone has written a script that does this (so it can be scheduled) that would be awesome.

like image 534
Ben Foster Avatar asked Oct 21 '11 09:10

Ben Foster


People also ask

How do I restore my Azure database to local?

Right click on source database and select Tasks > Export Data-tier Application... On the below screen click Next. Choose a directory, name the file and Save the *. bacpac file locally.

Can we restore Bacpac file in SQL Server?

You can not directly restore this type of file but have to follow a few steps to import it into your database with us. To do this you will need the latest SQL Server Management Studio (SSMS), a local instance of SQL Server, either Express or any full version, and your . bacpac file.

How do you backup Azure SQL database and restore locally?

Connect to your SQL Azure database that you want to copy locally using SQL Server Management Studio (SSMS). Export your database to a local . bacpac file. Follow steps in wizard and finish the process.

Can I restore BAK file to Azure SQL Database?

Currently Azure doesn't support restoring the database on Azure SQL Instance using the backup (. bak) file. But there are many other ways to migrate the SQL Database to Azure SQL.


2 Answers

This can be done simply through SQL Server Management Studio 2012

  1. Right click on the Connection > Databases node and select "Import Data-tier application..."
  2. Select "Next" on the introduction step.
  3. enter image description here
  4. Browse, or connect to a storage account where backups are kept.
like image 194
Josiah Ruddell Avatar answered Sep 22 '22 04:09

Josiah Ruddell


I needed to export a SQL Azure database and then import it into a local SQL 2008 R2 server (Note I am also using Visual Studio 2010). Microsoft certainly went out of their way to make this a painful task, however, I was able to do it by doing the following:

  1. Goto this link http://msdn.microsoft.com/en-us/jj650014 and install the SQL Server Data Tools for Visual Studio 2010

  2. This will install on your local drive. In my case here is where it put it: C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin

  3. Browse to this via the command line or powershell

  4. You are going to want to execute the SqlPackage.exe

  5. Open up this link to see a list of all the parameter options for SqlPackage.exe (http://msdn.microsoft.com/en-us/library/hh550080(v=vs.103).aspx)

  6. Here is my command line that I needed to execute to import a .bacpac file into my local SQL 2008 R2 server:

    .\SqlPackage.exe /a:Import /sf:C:\mydatabasefile.bacpac /tdn:NorthWind /tsn:BINGBONG

/tdn is the name of the database you want your bacpac file to restore to. /tsn is the name of your SQL server.

You can see all these parameter descriptions on the link from #5.

like image 41
Flea Avatar answered Sep 22 '22 04:09

Flea