如何将远程SQL Server数据库备份到本地驱动器? [英] How can I backup a remote SQL Server database to a local drive?

查看:301
本文介绍了如何将远程SQL Server数据库备份到本地驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将数据库从远程服务器复制到本地服务器.我尝试使用SQL Server Management Studio,但它仅备份到远程服务器上的驱动器.

I need to copy a database from a remote server to a local one. I tried to use SQL Server Management Studio, but it only backs up to a drive on the remote server.

一些要点:

  • 我无法以可以复制文件的方式访问远程服务器;
  • 我无权设置服务器的UNC路径;

关于如何复制此数据库的任何想法?我需要使用第三方工具吗?

Any ideas of how can I copy this database? Will I have to use 3rd party tools?

推荐答案

在Microsoft SQL Server Management Studio中,您可以右键单击要备份的数据库,然后单击任务->生成脚本".

In Microsoft SQL Server Management Studio you can right-click on the database you wish to backup and click Tasks -> Generate Scripts.

这会弹出一个向导,您可以在其中设置以下内容以对数据库进行不错的备​​份,甚至在远程服务器上:

This pops open a wizard where you can set the following in order to perform a decent backup of your database, even on a remote server:

  • 选择要备份的数据库,然后单击下一步,
  • 在显示给您的选项中:
  • Select the database you wish to backup and hit next,
  • In the options it presents to you:
  1. 2010年:在表/视图"选项下,将脚本数据"和脚本索引"更改为True,然后单击下一步,
  2. 2012年:在常规"下,将数据类型为脚本"从仅模式"更改为模式和数据"
  3. 在2014年:现在,在设置脚本选项"步骤中隐藏"脚本数据的选项,您必须单击高级",并将脚本的数据类型"设置为架构和数据"值

  • 在接下来的四个窗口中,点击全选",然后点击下一步,
  • 选择脚本编写到新的查询窗口
  • In the next four windows, hit 'select all' and then next,
  • Choose to script to a new query window
  • 完成操作后,您将准备好一个备份脚本.创建一个新的本地(或远程)数据库,并在脚本中更改第一个"USE"语句以使用您的新数据库.将脚本保存在安全的地方,然后继续对新的空数据库运行该脚本.这将为您创建一个(几乎)重复的本地数据库,然后您可以根据需要进行备份.

    Once it's done its thing, you'll have a backup script ready in front of you. Create a new local (or remote) database, and change the first 'USE' statement in the script to use your new database. Save the script in a safe place, and go ahead and run it against your new empty database. This should create you a (nearly) duplicate local database you can then backup as you like.

    如果您具有对远程数据库的完整访问权限,则可以选择在向导的第一个窗口中检查脚本所有对象",然后在下一个窗口中将脚本数据库"选项更改为True. .请注意,您需要执行完整的搜索和&将脚本中的数据库名称替换为新数据库,在这种情况下,您无需在运行脚本之前创建数据库.这样可以创建更准确的副本,但由于权限限制,有时无法使用.

    If you have full access to the remote database, you can choose to check 'script all objects' in the wizard's first window and then change the 'Script Database' option to True on the next window. Watch out though, you'll need to perform a full search & replace of the database name in the script to a new database which in this case you won't have to create before running the script. This should create a more accurate duplicate but is sometimes not available due to permissions restrictions.

    这篇关于如何将远程SQL Server数据库备份到本地驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆