如何将 SQL Azure 数据库复制到本地开发服务器?

发布于 2024-10-27 22:33:57 字数 126 浏览 1 评论 0原文

有谁知道如何将 SQL Azure 数据库复制到我的开发计算机上?我想停止付费在云中拥有开发数据库,​​但这是获取生产数据的最佳方式。我将生产数据库复制到新的开发数据库,​​但我希望在本地拥有相同的数据库。

有什么建议吗?

Does anyone know how I can copy a SQL Azure database to my development machine? I'd like to stop paying to have a development database in the cloud, but it's the best way to get production data. I copy my production database to a new development database but I'd like to have that same database local.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(25

往日 2024-11-03 22:33:57

将 Azure 数据库数据复制到本地数据库:
现在您可以使用 SQL Server Management Studio 执行以下操作:

  • 连接到 SQL Azure 数据库。
  • 右键单击对象资源管理器中的数据库。
  • 选择选项“任务”/“将数据库部署到 SQL Azure”。
  • 在名为“部署设置”的步骤中,连接本地 SQL Server 并创建新数据库。

在此处输入图像描述

下一步 -> 下一步 -> 完成

Copy Azure database data to local database:
Now you can use the SQL Server Management Studio to do this as below:

  • Connect to the SQL Azure database.
  • Right click the database in Object Explorer.
  • Choose the option "Tasks" / "Deploy Database to SQL Azure".
  • In the step named "Deployment Settings", connect local SQL Server and create New database.

enter image description here

Next -> Next -> Finish

邮友 2024-11-03 22:33:57

有多种方法可以做到这一点:

  1. 使用 SSIS(SQL Server 集成服务)。它仅导入表中的数据。列属性、约束、键、索引、存储过程、触发器、安全设置、用户、登录名等不会传输。然而,这是一个非常简单的过程,只需通过 SQL Server Management Studio 中的向导即可完成。
  2. 使用SSIS 和数据库创建脚本的组合。这将为您提供数据以及所有未由 SSIS 传输的缺失元数据。这也很简单。首先使用 SSIS 传输数据(请参阅下面的说明),然后从 SQL Azure 数据库创建 DB Create 脚本,并在本地数据库上重新运行它。
  3. 最后,您可以使用SQL Azure 中的导入/导出服务。这会将数据(带有架构对象)作为 BACPAC 传输到 Azure Blob 存储。您将需要一个 Azure 存储帐户并在 Azure Web 门户中执行此操作。只需在选择要导出的数据库时按 Azure Web 门户中的“导出”按钮即可。缺点是它只是手动过程,我不知道通过工具或脚本自动执行此操作的方法 - 至少是需要单击网页的第一部分。

方法#1(使用 SSIS)的手动过程如下:

  • 在 Sql Server Management Studio (SSMS) 中,在本地 SQL 实例上创建新的空数据库。
  • 从上下文菜单中选择导入数据(右键单击数据库 -> 任务 -> 导入数据...)
  • 键入源 (SQL Azure) 的连接参数。选择“.Net Framework Data Provider for SqlServer”作为提供程序。
  • 选择现有的空本地数据库作为目标。
  • 按照向导操作 - 您将能够选择要复制的表数据。您可以选择跳过任何不需要的表。例如,如果您将应用程序日志保存在数据库中,则您的备份中可能不需要它。

您可以通过创建 SSIS 包并在需要重新导入数据时重新执行它来自动化它。请注意,您只能使用 SSIS 导入到干净的数据库,一旦完成一次就无法对本地数据库进行增量更新。

方法#2(SSID 数据加模式对象)非常简单。首先执行上述步骤,然后创建数据库创建脚本(右键单击 SSMS 中的数据库,选择生成脚本 -> 数据库创建)。然后在本地数据库上重新运行此脚本。

方法#3在博客中进行了描述:http://dacguy.wordpress.com/2012/01/24/sql-azure-importexport-service-has-hit-product/。有一个视频剪辑,介绍了将数据库内容传输到 Azure Blob 存储作为 BACPAC 的过程。之后,您可以在本地复制该文件并将其导入到您的 SQL 实例。将 BACPAC 导入数据层应用程序的过程如下所述:http://msdn。 microsoft.com/en-us/library/hh710052.aspx

There are multiple ways to do this:

  1. Using SSIS (SQL Server Integration Services). It only imports data in your table. Column properties, constraints, keys, indices, stored procedures, triggers, security settings, users, logons, etc. are not transferred. However it is very simple process and can be done simply by going through wizard in SQL Server Management Studio.
  2. Using combination of SSIS and DB creation scripts. This will get you data and all missing metadata that is not transferred by SSIS. This is also very simple. First transfer data using SSIS (see instructions below), then create DB Create script from SQL Azure database, and re-play it on your local database.
  3. Finally, you can use Import/Export service in SQL Azure. This transfers data (with a schema objects) to Azure Blob Storage as a BACPAC. You will need an Azure Storage account and do this in Azure web portal. It is as simple as pressing an "Export" button in the Azure web portal when you select the database you want to export. The downside is that it is only manual procedure, I don't know a way to automate this through tools or scripts -- at least the first part that requires a click on the web page.

Manual procedure for method #1 (using SSIS) is the following:

  • In Sql Server Management Studio (SSMS) create new empty database on your local SQL instance.
  • Choose Import Data from context menu (right click the database -> Tasks -> Import data...)
  • Type in connection parameters for the source (SQL Azure). Select ".Net Framework Data Provider for SqlServer" as a provider.
  • Choose existing empty local database as destination.
  • Follow the wizard -- you will be able to select tables data you want to copy. You can choose to skip any of the tables you don't need. E.g. if you keep application logs in database, you probably don't need it in your backup.

You can automate it by creating SSIS package and re-executing it any time you like to re-import the data. Note that you can only import using SSIS to a clean DB, you cannot do incremental updates to your local database once you already done it once.

Method #2 (SSID data plus schema objects) is very simple. First go though a steps described above, then create DB Creation script (righ click on database in SSMS, choose Generate Scripts -> Database Create). Then re-play this script on your local database.

Method #3 is described in the Blog here: http://dacguy.wordpress.com/2012/01/24/sql-azure-importexport-service-has-hit-production/. There is a video clip with the process of transferring DB contents to Azure Blob storage as BACPAC. After that you can copy the file locally and import it to your SQL instance. Process of importing BACPAC to Data-Tier application is described here: http://msdn.microsoft.com/en-us/library/hh710052.aspx.

对不⑦ 2024-11-03 22:33:57

在 SQL Server 2016 Management Studio 中,将 Azure 数据库获取到本地计算机的过程已得到简化。

右键单击要导入的数据库,单击任务>导出数据层应用程序,并将数据库导出到本地 .dacpac 文件。

在本地目标 SQL Server 实例中,您可以右键单击数据库 >导入数据层应用程序,一旦它是本地的,您就可以执行诸如备份和恢复数据库之类的操作。

In SQL Server 2016 Management Studio, the process for getting an azure database to your local machine has been streamlined.

Right click on the database you want to import, click Tasks > Export data-tier application, and export your database to a local .dacpac file.

In your local target SQL server instance, you can right click Databases > Import data-tier application, and once it's local, you can do things like backup and restore the database.

£烟消云散 2024-11-03 22:33:57

我只是想添加 dumbledad 的答案 的简化版本,因为它是正确的。

  1. 将 Azure SQL 数据库导出到 Blob 存储上的 BACPAC 文件。
  2. 在 SQL Management studio 中,右键单击数据库,单击“导入数据层应用程序”。
  3. 系统将提示你输入信息以获取 Azure Blob 存储上的 BACPAC 文件。
  4. 点击下一步几次然后......完成!

I just wanted to add a simplified version of dumbledad's answer, since it is the correct one.

  1. Export the Azure SQL Database to a BACPAC file on blob storage.
  2. From inside SQL Management studio, right-click your database, click "import data-tier application".
  3. You'll be prompted to enter the information to get to the BACPAC file on your Azure blob storage.
  4. Hit next a couple times and... Done!
守护在此方 2024-11-03 22:33:57

我认为现在容易多了。

  1. 启动 SQL Management Studio
  2. 右键单击​​“数据库”并选择“导入数据层应用程序...”
  3. 向导将引导您完成连接到 Azure 帐户、创建 BACPAC 文件和创建数据库的过程。

此外,我使用 Sql Backup 和 FTP (https://sqlbackupandftp.com/) 每日备份到安全的 FTP 服务器。我只需从那里提取最近的 BACPAC 文件并将其导入到同一个对话框中,这样可以更快、更轻松地创建本地数据库。

I think it is a lot easier now.

  1. Launch SQL Management Studio
  2. Right Click on "Databases" and select "Import Data-tier application..."
  3. The wizard will take you through the process of connecting to your Azure account, creating a BACPAC file and creating your database.

Additionally, I use Sql Backup and FTP (https://sqlbackupandftp.com/) to do daily backups to a secure FTP server. I simply pull a recent BACPAC file from there and it import it in the same dialog, which is faster and easier to create a local database.

小霸王臭丫头 2024-11-03 22:33:57

您还可以查看 Windows Azure 管理门户中的 SQL Azure 数据同步。它允许您检索和恢复整个数据库,包括 SQL Azure 和 SQL Server 之间的架构和数据。

You can also check out SQL Azure Data Sync in the Windows Azure Management Portal. It allows you to retrieve and restore an entire database, including schema and data between SQL Azure and SQL Server.

守望孤独 2024-11-03 22:33:57

使用 msdeploy.exe

警告:msdeploy.exe 无法自行创建目标数据库,因此您需要先手动创建它。

  1. 复制数据库属性页上的连接字符串。对其进行调整,使其包含正确的密码。
    数据库属性页
  2. 获取目标数据库的连接字符串。
  3. 像这样运行msdeploy.exe

    "c:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -dest:dbDacFx="destination_DB_connection_string",dropDestinationDatabase=true -source:dbDacFx="azure_DB_connection_string",includeData =true-详细
    

使用 SqlPackage.exe

  1. 将 azure DB 导出到 bacpac 包。

    "c:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /a:Export /ssn:"azure_db_server" /sdn:"azure_db_name" /su:"用户名" /sp:"密码" /tf:"文件.bacpac"
    
  2. 将包导入到本地数据库。

    "c:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /a:Import /SourceFile:"file.bacpac" /TargetServerName:".\SQLEXPRESS" /目标数据库名称:CopyOfAzureDb
    

Using msdeploy.exe

Caveat: msdeploy.exe fails to create the destination database on its own, so you need to create it manually first.

  1. Copy the connection string on the database properties page. Adjust it so that it contains a correct password.
    database properties page
  2. Get the connection string for the destination DB.
  3. Run msdeploy.exe like this:

    "c:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -dest:dbDacFx="destination_DB_connection_string",dropDestinationDatabase=true -source:dbDacFx="azure_DB_connection_string",includeData=true -verbose
    

Using SqlPackage.exe

  1. Export the azure DB to a bacpac package.

    "c:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /a:Export /ssn:"azure_db_server" /sdn:"azure_db_name" /su:"user_name" /sp:"password" /tf:"file.bacpac"
    
  2. Import the package to a local DB.

    "c:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /a:Import /SourceFile:"file.bacpac" /TargetServerName:".\SQLEXPRESS" /TargetDatabaseName:CopyOfAzureDb
    
执手闯天涯 2024-11-03 22:33:57

这很容易。这对我有用...将 Azure SQL 数据库下载到本地计算机...:

  1. 打开 SQL Management Studio 并连接到 Azure SQL Server。
  2. 选择您想要下载到本地计算机上的数据库,然后右键单击...选择“生成脚本”。按照提示操作...

但是,请注意,如果您还需要数据以及脚本,请务必在开始生成之前检查高级选项...向下滚动到“要编写脚本的数据类型”,并确保您有“架构和数据”...或任何适合您的内容。

它会给你一个很好的 SQL 脚本文件,然后可以在你的本地计算机上运行它,它将创建数据库并用所有数据填充它。

请记住,就我而言,我没有 FK 或其他限制......而且,数据也不是很多。

我一般不建议将此作为备份机制......

It's pretty easy. This worked for me...in terms of getting an Azure SQL database down onto your local machine...:

  1. Open your SQL Management Studio and connect to your Azure SQL Server.
  2. Select the database you would like to get down onto your local machine, and right-click...select "Generate Scripts". Follow the prompts...

BUT, be careful in that if you ALSO want the DATA, as well as the scripts, be sure to check the Advanced Options before beginning the generating...scroll down to "Types of data to script", and make sure you have "Schema and data"...or whatever is appropriate for you.

It will give you a nice SQL script file which can then be run on your local machine and it will create the database as well as populate it with all the data.

Bare in mind that in my case, I have no FK or other constraints...also, it wasn't a lot of data.

I don't recommend this as a backup mechanism in general...

烟雨扶苏 2024-11-03 22:33:57

在 SQL Server Management Studio 中

右键单击要导入的数据库,单击“任务”>“导入”。导出数据层应用程序,并将数据库导出到本地 .dacpac 文件。

在本地目标 SQL Server 实例中,您可以右键单击“数据库”>“数据库”>“数据库”。导入数据层应用程序,一旦它是本地的,您就可以执行诸如备份和恢复数据库之类的操作。

In SQL Server Management Studio

Right click on the database you want to import, click Tasks > Export data-tier application, and export your database to a local .dacpac file.

In your local target SQL server instance, you can right click Databases > Import data-tier application, and once it's local, you can do things like backup and restore the database.

深海不蓝 2024-11-03 22:33:57

看起来 2022 年 Management Studio 中缺少该功能。以下是我使用 Azure Data Studio 执行此操作的方法:

  1. 安装 Azure Data Studio
  2. 打开 Azure Data Studio
  3. 安装名为 Admin Pack for SQL Server 的扩展
  4. 重新启动 Azure Data Studio
  5. 为两个源数据库设置连接(Azure) 和目标(本地计算机)
  6. 在主数据库上的本地数据库引擎中执行语句:
    sp_configure '包含数据库身份验证', 1; 
    去  
    重新配置;
    去
    
  7. 右键单击源数据库并选择数据层应用程序向导。
    选择导出到 .bacpac 文件 [导出 bacpac](我当前版本中的第四个选项,最后一个选项)
  8. 完成向导
  9. 右键单击​​目标数据库并选择数据层应用程序向导
  10. 选择从 .bacpac 导入 [导入 bacpac](我的版本中的第三个选项)
  11. 选择之前创建的 .bacpac 文件并完成向导导入

后,将创建登录名和用户,但未设置其默认架构。如果需要默认模式,则需要手动处理。在这种情况下:

打开与本地副本的管理连接并运行:

USE [imported-db];

ALTER USER imported-user WITH DEFAULT_SCHEMA = whatever;

Looks like the functionality is missing from Management Studio in 2022. Here is how I do it using Azure Data Studio:

  1. Install Azure Data Studio
  2. Open Azure Data Studio
  3. Install the extension called Admin Pack for SQL Server
  4. Restart Azure Data Studio
  5. Setup connections for both source database (Azure) and destination (local machine)
  6. Execute statement in your local DB Engine on master database:
    sp_configure 'contained database authentication', 1; 
    GO  
    RECONFIGURE;
    GO
    
  7. Right click on source database and select Data-tier Application Wizard.
    Select Export to .bacpac file [Export bacpac] (4th, last option in my current version)
  8. Finish the wizard
  9. Right click on destination database and select Data-tier Application Wizard
  10. Select Import from .bacpac [Import bacpac] (3rd option in my version)
  11. Select the .bacpac file previously created and finish the wizard

After importing the logins and users are created, but their default schema isn’t set. If default schema is required that needs to be handled manually. In that case:

Open an admin connection to the local copy and run:

USE [imported-db];

ALTER USER imported-user WITH DEFAULT_SCHEMA = whatever;
娇纵 2024-11-03 22:33:57

使用 SSMS v18.9+,您可以使用将数据库部署到 Microsoft Azure SQL 数据库

它并不是很直观,但向导允许您选择本地数据库,即使任务名称是将数据库部署到 Microsoft Azure SQL 数据库

  1. 使用 SSMS 连接到 Azure 数据库
  2. 右键单击数据库,选择“任务”>“任务”。将数据库部署到 Microsoft Azure SQL 数据库。
    输入图片此处描述
  3. 选择您的本地 SQL 服务器作为目标连接。
    输入图片此处的说明
  4. 请执行其他步骤。

Using SSMS v18.9+, you can use the Deploy Database to Microsoft Azure SQL Database.

It's not really intuitive, but the wizard allow you to select a local db even if the name of the task is Deploy Database to Microsoft Azure SQL Database.

  1. Connect to your Azure Database using SSMS
  2. Right-click on the database, select Tasks > Deploy Database to Microsoft Azure SQL Database.
    enter image description here
  3. Select your local SQL server as the target connection.
    enter image description here
  4. Follow the additional steps.
给妤﹃绝世温柔 2024-11-03 22:33:57

我总是使用导入/导出功能,这似乎是最简单的功能。

第 1 步:

从 azure 实例获取备份,如下所示,选择数据库 → 右键单击​​ → 任务 → 导出数据层应用程序。

第 2 步:
为备份文件指定一个特定名称,并将其保存在您所需的位置

步骤 3: 这样您就已经将数据库从 sql 实例备份到本地。让我们将其恢复到本地。将备份的数据库复制到C盘。现在以管理员权限打开 PowerShell 并导航到 C 盘

第 4 步:让我们下载 powershell 脚本来删除主服务器keyRemoveMasterKey.ps1 在同一驱动器上有脚本,在本例中为 C

第 5 步:运行脚本如下,
.\RemoveMasterKey.ps1 -bacpacPath "C:\identity.bacpac"

就是这样,现在您可以在本地环境中的 MSSQL 2017 上恢复它。

第 6 步: 连接到本地服务器,然后单击“数据库”→“导入数据层-应用程序”

第 7 步:为要恢复的数据库指定名称。

现在你会看到一切都是绿色的!

阅读我的博客 带有图表。

I always use Import/Export Feature which seems to be the easiest one among all.

Step 1:

Get the backup from the azure instance as follows, Select the database → Right click → Tasks → Export Data Tier Application.

Step 2:
Give a specific name for the backup file and save it in your desired location

Step 3: That's it you have taken a backup of the database from sql instance to your local. Lets restore it to the local. Copy the backed up database to your C drive. Now open the PowerShell with administrator rights and navigate to C drive

Step 4: Lets download the powershell script to remove the master keyRemoveMasterKey.ps1 have the script on the same drive in this case its C.

Step 5 : Run the script as follows,
.\RemoveMasterKey.ps1 -bacpacPath "C:\identity.bacpac"

That's it, now you can restore it on MSSQL 2017 in your local environment.

Step 6: Connect to your local server, and click Databases → Import-Data-Tier-Application

Step 7 : Give a name for your database to restore.

Now you will see everything in green!

Read my blog with diagrams.

a√萤火虫的光℡ 2024-11-03 22:33:57

我无法让 SSIS 导入/导出工作,因为我收到错误“插入只读列“id”失败”。我也无法让 http://sqlazuremw.codeplex.com/ 工作,并且上面的链接到 SQL Azure数据同步对我不起作用。

但我发现了一篇关于 BACPAC 文件的优秀博客文章:http://dacguy.wordpress.com/2012/01/24/sql-azure-importexport-service-has-hit-product/

帖子中的视频博客文章的作者介绍了六个步骤:

  1. 在 Azure 管理门户中创建或转到存储帐户。
    您将需要 Blob URL 和存储的主访问密钥
    帐户。

  2. 该博客文章建议为 bacpac 文件创建一个新容器,并
    建议使用 Azure 存储
    资源管理器
    为此。 (注:
    您将需要 Blob URL 和存储的主访问密钥
    帐户将其添加到 Azure 存储资源管理器。)

  3. 在 Azure 管理门户中选择您想要的数据库
    导出并单击“导入和导出”部分中的“导出”
    丝带。

  4. 出现的对话需要您的用户名和密码
    数据库、blob URL 和访问密钥。不要忘记包括
    blob URL 中的容器并包含文件名(例如
    https://testazurestorage.blob.core.windows.net/dbbackups/mytable.bacpac )。

  5. 单击“完成”后,数据库将导出到 BACPAC
    文件。这可能需要一段时间。您可能会看到出现一个零字节文件
    如果您签入 Azure 存储资源管理器,请立即查看。这是
    导入/导出服务检查它是否具有对
    blob 商店。

  6. 完成后,您可以使用 Azure 存储资源管理器下载
    BACPAC 文件,然后在 SQL Server Management Studio 中
    右键单击本地服务器的数据库文件夹并选择导入
    数据层应用程序将启动读取的向导
    BACPAC 文件来生成 Azure 数据库的副本。巫师
    还可以直接连接到 blob-store 来获取 BACPAC
    如果您不想先将其复制到本地,则

最后一步可能仅在 SQL Server Management Studio 的 SQL Server 2012 版本(即我正在运行的版本)中可用。我没有这台机器上的早期版本可供检查。在博客文章中,作者使用命令行工具 DacImportExportCli.exe 进行导入,我相信可以在 http:// sqldacexamples.codeplex.com/releases

I couldn't get the SSIS import / export to work as I got the error 'Failure inserting into the read-only column "id"'. Nor could I get http://sqlazuremw.codeplex.com/ to work, and the links above to SQL Azure Data Sync didn't work for me.

But I found an excellent blog post about BACPAC files: http://dacguy.wordpress.com/2012/01/24/sql-azure-importexport-service-has-hit-production/

In the video in the post the blog post's author runs through six steps:

  1. Make or go to a storage account in the Azure Management Portal.
    You'll need the Blob URL and the Primary access key of the storage
    account.

  2. The blog post advises making a new container for the bacpac file and
    suggests using the Azure Storage
    Explorer
    for that. (N.B.
    you'll need the Blob URL and the Primary access key of the storage
    account to add it to the Azure Storage Explorer.)

  3. In the Azure Management Portal select the database you want to
    export and click 'Export' in the Import and Export section of the
    ribbon.

  4. The resulting dialogue requires your username and password for the
    database, the blob URL, and the access key. Don't forget to include
    the container in the blob URL and to include a filename (e.g.
    https://testazurestorage.blob.core.windows.net/dbbackups/mytable.bacpac).

  5. After you click Finish the database will be exported to the BACPAC
    file. This can take a while. You may see a zero byte file show up
    immediately if you check in the Azure Storage Explorer. This is the
    Import / Export Service checking that it has write access to the
    blob-store.

  6. Once that is done you can use the Azure Storage Explorer to download
    the BACPAC file and then in the SQL Server Management Studio
    right-click your local server's database folder and choose Import
    Data Tier Application that will start the wizard which reads in the
    BACPAC file to produce the copy of your Azure database. The wizard
    can also connect directly to the blob-store to obtain the BACPAC
    file if you would rather not copy it locally first.

The last step may only be available in the SQL Server 2012 edition of the SQL Server Management Studio (that's the version I am running). I do not have earlier ones on this machine to check. In the blog post the author uses the command line tool DacImportExportCli.exe for the import which I believe is available at http://sqldacexamples.codeplex.com/releases

花落人断肠 2024-11-03 22:33:57

关于“我无法让 SSIS 导入/导出工作,因为我收到错误“插入只读列“id”失败”。
这可以通过在映射屏幕中指定您确实希望允许插入 Identity 元素来解决。

之后,使用 SQL 导入/导出向导从 Azure 复制到本地数据库,一切正常。

我只有 SQL Server 2008 R2 附带的 SQL 导入/导出向导(工作正常)和 Visual Studio 2012 Express 来创建本地数据库。

Regarding the " I couldn't get the SSIS import / export to work as I got the error 'Failure inserting into the read-only column "id"'.
This can be gotten around by specifying in the mapping screen that you do want to allow Identity elements to be inserted.

After that, everything worked fine using SQL Import/Export wizard to copy from Azure to local database.

I only had SQL Import/Export Wizard that comes with SQL Server 2008 R2 (worked fine), and Visual Studio 2012 Express to create local database.

真心难拥有 2024-11-03 22:33:57

接受的答案已过时。我找到了更好的答案:使用导入数据层应用程序

更详细的信息请参阅这篇文章:
将 Azure SQL 数据库恢复到本地服务器

The accepted answer is out of date. I found a better answer: Use Import Data-tier Application

More detailed information please see this article:
Restoring Azure SQL Database to a Local Server

反差帅 2024-11-03 22:33:57

您可以尝试使用“SQL数据库迁移向导”工具。
该工具提供从 azure sql 导入和导出数据的选项。

请在此处查看更多详细信息。

https://sqlazuremw.codeplex.com/

You can try with the tool "SQL Database Migration Wizard".
This tool provide option to import and export data from azure sql.

Please check more details here.

https://sqlazuremw.codeplex.com/

一笑百媚生 2024-11-03 22:33:57

您可以使用新的 Azure 移动服务每晚将备份从 SQL Azure 导出到 Azure 存储中托管的 .bacpac 文件。该解决方案是 100% 云,不需要第三方工具,也不需要本地托管 SQL Server 实例来下载/复制/备份任何内容。

大约有 8 个不同的步骤,但都很简单:
http://geekswithblogs.net/BenBarreth/archive/2013/04/15/how-to-create-a-nightly-backup-of-your-sql-azure.aspx

You can use the new Azure Mobile Services to do a nightly backup export from SQL Azure to a .bacpac file hosted in Azure Storage. This solution is 100% cloud, doesn't require a 3rd party tool and doesn't require a local hosted SQL Server instance to download/copy/backup anything.

There's about 8 different steps, but they're all easy:
http://geekswithblogs.net/BenBarreth/archive/2013/04/15/how-to-create-a-nightly-backup-of-your-sql-azure.aspx

快乐很简单 2024-11-03 22:33:57

下载 Optillect SQL Azure Backup - 它有 15 天试用期,所以它将足以移动您的数据库:)

Download Optillect SQL Azure Backup - it has 15-day trial, so it will be enough to move your database :)

意中人 2024-11-03 22:33:57

对我来说,诀窍是开始在空数据库上复制 PKs/FKs/constraints,然后在导入数据时暂时禁用约束(请参阅 https://stackoverflow.txt)。 com/a/161410)。

更准确地说:

  1. 手动创建空目标数据库;
  2. 右键单击源数据库>任务>生成脚本;
  3. 在空目标数据库上运行脚本文件(现在数据库具有正确的 PK/FK/约束,但没有数据);
  4. 禁用所有约束;
  5. 导入数据(右键目标数据库>任务>导入数据);
  6. 重新启用约束。

希望这有帮助!

The trick for me was to start replicating PKs/FKs/constraints on empty DB, then temporarily disable constraints while importing data (see https://stackoverflow.com/a/161410).

More precisely:

  1. Create empty target DB manually;
  2. Right-click source DB > Tasks > Generate Scripts;
  3. Run script file on empty target DB (now DB has correct PKs/FKs/constraints, but no data);
  4. Disable all constraints;
  5. Import data (Right-click target DB > Tasks > Import Data);
  6. Re-enable constraints.

Hope this helps!

娇女薄笑 2024-11-03 22:33:57

现在您可以使用 SQL Server Management Studio 来执行此操作。

  • 连接到 SQL Azure 数据库。
  • 右键单击对象资源管理器中的数据库。
  • 选择选项“任务”/“将数据库部署到 SQL Azure”。
  • 在名为“部署设置”的步骤中,选择您的本地数据库连接。
  • “下一步”/“下一步”/“完成”...

Now you can use the SQL Server Management Studio to do this.

  • Connect to the SQL Azure database.
  • Right click the database in Object Explorer.
  • Choose the option "Tasks" / "Deploy Database to SQL Azure".
  • In the step named "Deployment Settings", select your local database connection.
  • "Next" / "Next" / "Finish"...
策马西风 2024-11-03 22:33:57

使用 SQL Azure 中的导入/导出服务创建 .bacpac 文件。

然后在另一篇 Stack Overflow 文章中看看这个方法。

Azure SQL 数据库 Bacpac 本地还原

Use the Import/Export service in SQL Azure to create a .bacpac file.

Then take a look at this method in another Stack Overflow article.

Azure SQL Database Bacpac Local Restore

内心旳酸楚 2024-11-03 22:33:57

如果有人在导入使用Azure SQL Sync的数据库的 Bacpac 时遇到问题,Sandrino Di Mattia 开发了很棒的简单应用程序来解决这个问题。

  1. Bacpac
  2. 导出数据库下载 Di Mattia 的 二进制文件< /a>
  3. 使用此控制台应用程序修复下载的 Bacpac
  4. Lauch SSMS
  5. 右键单击​​“数据库”并选择“导入数据层应用程序”
  6. 选择修复的 Bacpac。

If anyone has a problem to import a Bacpac of a DB that uses Azure SQL Sync, Sandrino Di Mattia developed a great simple application to solve this.

  1. Export a Bacpac of your DB
  2. Dowload Di Mattia's binary
  3. With this console app repair the downloaded Bacpac
  4. Lauch SSMS
  5. Right Click on "Databases" and select "Import Data-tier Application"
  6. Select the repaired Bacpac.
苍风燃霜 2024-11-03 22:33:57

如果有人想要一个免费且有效的选项(并且不介意手动执行)将数据库备份到本地,请使用最新版本 Microsoft Visual Studio 2015 Community Edition(免费)或 Professional / Premium / Ultimate 中内置的架构和数据比较功能版。它就像一个魅力!

我有Azure的BizPark帐户,没有办法直接备份数据库而不付费。我在VS中找到了这个选项。

答案取自 https://stackoverflow.com/a/685073/6796187

If anyone wants a free and effective option (and don't mind doing it manually) to backup database to Local then use schema and data comparison functionality built into the latest version Microsoft Visual Studio 2015 Community Edition (Free) or Professional / Premium / Ultimate edition. It works like a charm!

I have BizPark account with Azure and there is no way to backup database directly without paying. I found this option in VS works.

Answer is taken from https://stackoverflow.com/a/685073/6796187

杀手六號 2024-11-03 22:33:57

您好,我正在使用 SQLAzureMW 工具进行 SQLAzure DB 迁移和管理。非常有用的一个。它是从 codeplex 下载的,但目前不可用,codeplex 将关闭,相同的应用程序工具现在可以在 GttHub 中使用。下面的链接解释了如何使用此工具,并且还提供应用程序下载。

https: //github.com/twright-msft/azure-content/blob/master/articles/sql-database/sql-database-migration-wizard.md

Hi I'm using the SQLAzureMW tool for SQLAzure DB migration and management. Very useful one. It was downloaded from codeplex, but currently it's not available the codeplex will be going to shutdown, the same application tool is now available in GttHub. This below link is explain how to use this tool and also available the Application for download.

https://github.com/twright-msft/azure-content/blob/master/articles/sql-database/sql-database-migration-wizard.md

時窥 2024-11-03 22:33:57

1- 获取数据库 bacpac 文件:

  • 转到 Azure Sql Server 实例
  • 转到数据库
  • 通过单击导出按钮并完成向导来获取数据库 bacpac(您需要存储资源来存储 bacpac 文件)
  • 转到存储您已在上一步中指定并下载 bacpac 文件。

2- 在本地计算机上恢复 bacpac 文件:

  • 在本地计算机上安装 SQL Server。
  • 下载 Azure Data Studio 并连接到上一步中安装的服务器。
  • 在 Azure Data Studio 中安装 SQL Server dacpac 扩展。
  • 右键单击 SQL 服务器,然后选择数据层应用程序向导
  • 选择从 .bacpac 文件创建数据库
  • 填写必填字段。
  • 完毕

1- Get your database bacpac file:

  • Go to your Azure Sql Server instance
  • Go to your database
  • Get your database bacpac by clicking on the export button and finishing the wizard (you need a storage resource to store your bacpac file)
  • Go to the storage that you have specified in the previous step and download the bacpac file.

2- Restoring the bacpac file on your local machine:

  • Install a SQL Server on your local machine.
  • Download Azure Data Studio and connect to the server installed in previous step.
  • Install SQL Server dacpac extension in Azure Data Studio.
  • Right click on your SQL server and select Data-tier Application Wizard
  • Select Create a database from a .bacpac file
  • Fill the required fields.
  • Done
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文