在 SQL 2008 中恢复多个数据库的最有效方法是什么

发布于 2024-09-16 06:08:51 字数 383 浏览 3 评论 0原文

我正在进行大规模服务器迁移,因此我必须将 50 多个 SQL 2005 数据库迁移到新的 SQL 2008 服务器安装。

数据库人员只给了我每个数据库的备份,因此我需要恢复一个目录(即 c:\db),其中包含大约 50 个 .bak 文件。

我需要将每个数据库恢复到新服务器。

我可以在 Management Studio 中单独执行此操作,但这会很耗时。有没有更有效的方法来解决这个问题。

所以我的问题是:

恢复所有这些数据库的最有效方法是什么。

机器背景: 服务器是Win 2k8,带有SQL 2008 Workgroup Edition,.net 4与Powershell 2一起安装。

提前致谢。

I'm in the process of doing a large scale server migration, as such I have to move 50+ SQL 2005 databases to a new SQL 2008 server installation.

The DB guys have only given me a backup of each database, so I have a directory with some 50 .bak files sitting in a directory (ie c:\db) that I need to restore.

I need to restore each database to the new server.

I can do this individually in Management Studio, but that would be time consuming. Is there a more efficient way of solving this problem.

So my question is:

What is the most efficient way of restoring all of these databases.

Machine background:
The server is Win 2k8, with SQL 2008 Workgroup Edition, .net 4 is installed along with Powershell 2.

Thanks in advance.

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

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

发布评论

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

评论(2

↙厌世 2024-09-23 06:08:51

评论后编辑:您可以编写恢复脚本,例如:

restore database DatabaseName
from disk = N'c:\dir\BackupFileName.bak'
with file = 1,  
move N'DatabaseName' to N'c:\dir\DatabaseName.mdf',  
move N'DatabaseName_log' to N'c:\dir\DatabaseName.ldf',  
stats = 10, 
recovery 

两行 move 行将文件移动到新服务器上的某个位置。通常,名称为 DatabaseName 和 DatabaseName_log,但它们可能有所不同。

使用恢复意味着:使数据库联机,而无需等待额外的日志恢复。

要生成这样的脚本,请单击“还原数据库”向导窗口中的“脚本”按钮(左上角),然后单击将操作编写为...

Edited after comment: you can script restores, like:

restore database DatabaseName
from disk = N'c:\dir\BackupFileName.bak'
with file = 1,  
move N'DatabaseName' to N'c:\dir\DatabaseName.mdf',  
move N'DatabaseName_log' to N'c:\dir\DatabaseName.ldf',  
stats = 10, 
recovery 

The two move lines move the files to a location on the new server. Usually the names are DatabaseName and DatabaseName_log, but they can vary.

With recovery means: bring database online without waiting for additional log restores.

To generate a script like this, click the Script button (top left) in the Restore Database wizard window, and click Script action to....

撩动你心 2024-09-23 06:08:51

编写自定义应用程序/脚本?您可以扩展 SSMS 或使用 SQL Server 工具编写一个应用程序,仅读取这些文件并将它们恢复到数据库。我知道在 .net 中是可能的,也可能使用 powershell 脚本。

如果要在生产迁移期间在短时间内完成此任务,那么这是高效的,否则编写应用程序的开销比手动执行 50 次恢复还要多!但如果你是一名开发人员并且你手动选择,那么你就太丢脸了! :)。

Write a custom application/script? You could extend SSMS or use SQL server tools to write an application that just reads these files and restores them to the database. I know it is possible in .net, might be possible using powershell scripts as well.

This is efficient if this task is to be done in a short period of time during the production migration, otherwise the overhead of writing the app is more than doing 50 restores manually! But if you are a developer and you choose manually, then shame on you! :).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文