在 SQL Server 2008 上恢复数据库

发布于 2024-11-14 21:07:19 字数 1459 浏览 1 评论 0原文

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

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

发布评论

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

评论(3

嘦怹 2024-11-21 21:07:19
  • 您可以在单击“确定”之前在 SSMS 中编写任务脚本
  • RESTORE 上的文档 在这里,但基本思想是 RESTORE DATABASE MyDB FROM DISK = 'F:\xxx.bak'

但是,此错误意味着文件已损坏或不完整。作为某些 FTP 或复制过程的一部分,它可能会被损坏。

一个随机的想法:SQL Server 帐户是否可以访问您的 F: 驱动器? (如果看不到该文件,我不记得错误,即使您可以在 Windows 资源管理器中看到)

  • You can script the task in SSMS, just before clicking the "OK"
  • The documentation on RESTORE is here, but the basic idea would be RESTORE DATABASE MyDB FROM DISK = 'F:\xxx.bak'

However, this error means the file is either corrupt or incomplete. It could be corrupt as part of some FTP or copy process.

One random thought: does the SQL Server account has access to your F: drive? (I don't remember the error if it can't see the file, even if you can in Windows Explorer)

呢古 2024-11-21 21:07:19

正如 gbn 所说,错误消息可能意味着 SQL Server 看到的 BAK 文件已损坏。它可能被网络损坏,或者存储 BAK 文件的磁盘或磁盘控制器可能已损坏。

这是一个恢复命令示例:

restore database [DatabaseName]
from  disk = N'c:\Restore\RestoreName.bak'
with file = 1,
    move N'DatabaseName_Data' to N'd:\mssql\data\DatabaseName_Data.MDF', 
    move N'DatabaseName_Log' to N'd:\mssql\data\DatabaseName_Log.LDF', 
     replace

Like gbn says, the error message probably means that the BAK file SQL Server sees is corrupt. It might be corrupted by the network, or the disks or disk controller that stores the BAK file might have gone bad.

Here's an example restore command:

restore database [DatabaseName]
from  disk = N'c:\Restore\RestoreName.bak'
with file = 1,
    move N'DatabaseName_Data' to N'd:\mssql\data\DatabaseName_Data.MDF', 
    move N'DatabaseName_Log' to N'd:\mssql\data\DatabaseName_Log.LDF', 
     replace
薄凉少年不暖心 2024-11-21 21:07:19

很确定您的备份已损坏,但为了测试它,我建议您使用以下命令:

RESTORE VERIFYONLY
FROM DISK = 'F:\xxx.bak'

这样,如果备份文件存在问题,您可以捕获它们,而不会在此过程中损坏数据库。但是,请注意,VERIFYONLY 不会捕获所有问题,并且如果备份不是使用 CHECKSUM 运算符进行的,则它将仅对备份文件进行标头检查。不过,有总比没有好。

Pretty sure you're backup is corrupt, but to test it, I'd suggest you use the following command:

RESTORE VERIFYONLY
FROM DISK = 'F:\xxx.bak'

That way, if there are issues with the backup file, you can catch them without possibly corrupting your database in the process. But, be warned, VERIFYONLY won't catch all issues, and if the backup was not taken with a CHECKSUM operator, it'll be a header only check of the backup file. Still, it's better than nothing.

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