问题描述
我正在尝试将 Azure 数据库备份到我的本地计算机,然后使用 Powershell 还原到 Azure 中的其他位置。 我正在使用的脚本是
# 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
但我收到错误:
Backup-sqlDatabase : System.Data.sqlClient.sqlError: Statement 'BACKUP DATABASE' is not
supported in this version of sql Server.
是否有不同的命令可以使用 Powershell 备份任何版本的 Azure 数据库?
解决方法
如果您使用的是 Azure SQL 数据库,那么根据文档,您将无法使用 BACKUP 命令,您只有自动备份而不是用户启动的备份,如果您使用的是 Azure SQL 托管实例,那么您确实可以使用该命令。
>您可以在此功能比较页面上看到两者之间的差异 Here