0

I am trying to backup an Azure database to my local machine and then restore to a different location in Azure using Powershell . My script I am using is

# Define clear text string for username and password
[string]$userName = '<username>'
[string]$userPassword = '<password>'

# Convert to SecureString
[securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($userName, 
     $secStringPassword)

Backup-SqlDatabase -ServerInstance "<server>.database.windows.net" -Database "TestDB" - 
     BackupFile "c:\testbackup.bak" -Credential $credObject 

But I am getting the error :

Backup-SqlDatabase : System.Data.SqlClient.SqlError: Statement 'BACKUP DATABASE' is not 
supported in this version of SQL Server.

Is there a different command to backup an Azure database that is any version using Powershell ?

1 Answers1

0

If you are using Azure SQL Database then the BACKUP command is not available to you as per the docs you only have automated backups not user initiated ones, if you are using Azure SQL Managed Instance then you do have the command.

You can see the differences between the two on this feature comparison page Here

Jonathan Waring
  • 241
  • 1
  • 5