是否可以将 Azure SQL 数据库复制到 SQL Server?

问题描述 投票:0回答:1
  • 生产数据库在 Azure SQL 上运行;
  • 临时数据库使用 Spot 节点池在 AKS 上 Kubernetes 集群内的 SQL Server 上运行。

现在,我需要一个新环境,并且这个新环境的数据库需要每天在最近的生产快照之上重新创建。

由于有多个数据库,我猜 Azure SQL 会很昂贵,所以我想使用 SQL Server,就像我已经在临时环境中所做的那样。

到目前为止我所做的:

  1. 使用 Azure 自动化运行手册(每天运行)将数据库作为 BACPAC 文件从 Azure SQL 导出到 Azure Blob 存储;
  2. 通过 SQL Server 上的共享访问签名配置 Azure Blob 存储的凭据(并且凭据正在工作,正如我测试的那样,并且能够将 SQL Server 数据库备份到 Blob 存储中,但这不是我想要的);
  3. 但是,当我运行
    RESTORE DATABASE [test1] FROM URL = 'https://<myblobaccount>.blob.core.windows.net/<container>/database_latest.bacpac'
    时,它失败了:

设备上的媒体系列 'https://.blob.core.windows.net//database_latest.bacpac' 形成不正确。 SQL Server 无法处理此媒体系列。

似乎无法将 Azure SQL 导出的 BACPAC 导入 SQL Server。

sql-server azure kubernetes azure-sql-database
1个回答
0
投票

设备“https://.blob.core.windows.net//database_latest.bacpac”上的媒体系列格式不正确。 SQL Server 无法处理此媒体系列。

此错误的原因是恢复数据库处理

.bak
文件,并且您向其提供
.bacpac
文件。

解决方案可以按照@Martin Smith的建议使用SqlPackage.exe实用程序包,但首先您需要从blob存储下载

.bacpac
文件,您可以在cmd/powershell中使用以下命令:

Invoke-WebRequest -Uri https://storage_acc_name.blob.core.windows.net/storage_cont_name/WideWorldImporters-Standard.bacpac -OutFile "C:\destination_path\WideWorldImporters-Standard.bacpac"

enter image description here

文件下载后,您可以使用 SqlPackage.exe 实用程序

将其导出
C:\Program Files\Microsoft SQL Server\160\DAC\bin>sqlpackage.exe /Action:Import /tsn:MSSQLSERVER01 /tdn:Importdb1 /tu:user /tp:password /sf:"C:\destination_path\WideWorldImporters-Standard.bacpac"

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.