Mel
Mel

Reputation: 351

How can i backup and Azure DB to local disk?

I have tried using the option Export Data-tier option but I get errors in all outputs Exporting Database Extracting Schema Extracting Schema from database

and there are no details about why it failed.\ Is there a way I can back it up on Azure and copy the bacpac file or with powershell ?

Upvotes: 0

Views: 2157

Answers (2)

Alberto Morillo
Alberto Morillo

Reputation: 15608

You can use SqlPackage to create a backup (export a bacpac) of your Azure SQL Database in your local drive.

sqlpackage.exe /Action:Export /ssn:tcp:sqlftpbackupserver.database.windows.net /sdn:sqlftpbackupdb /su:alberto /tf:c:\sql\sqlftpbackup.bacpac /sp:yourpwd /p:Storage=File

In above example, we are exporting a file (Export) to an Azure SQL Server named sqlftpbackupserver.database.windows.net and the source database name is sqlftpbackup. The source user is alberto and the target file where we will export is in the c:\sql\sqlftpbackup.bacpac sp is to specify the Azure SQL database password of the Azure SQL user. Finally, we will store in a file.

Another example is:

SqlPackage /Action:Export /SourceServerName:SampleSQLServer.sample.net,1433 
/SourceDatabaseName:SampleDatabase /TargetFile:"F:\Temp\SampleDatabase.bacpac"

Upvotes: 2

Leon Yue
Leon Yue

Reputation: 16401

You can try the backup the database to Blob Storage on Portal, then download it to your local disk. enter image description here

For Powershell, here's the Command example: Backup SQL Azure database to local disk only:

C:\PS>Backup-Database -Name “database1” -DownloadLocation “D:\temp” -Server “mydatabaseserver” -UserName “username”  -Password “password” -Verbose

For more details, reference Backup SQL Azure Database.

Here's a tutorial How to backup Azure SQL Database to Local Machine talks about almost all the ways to help you backup the Azure SQL Database to local disk: enter image description here enter image description here

Hope this helps.

Upvotes: 1

Related Questions