SQL Server,将 .BKP 文件还原到 MDF 文件,但不是 LDF(没有空间)

发布于 2024-07-12 23:08:07 字数 407 浏览 7 评论 0原文

我遇到的问题是,我没有足够的空间来容纳我们完成的 LiteSpeed 备份中的 MDF 和 LDF 文件。

我想出了以下存储过程:

exec master.dbo.xp_restore_database

@database = 'OSiteDB',
@filename = 'L:\OSiteDB_2009_01_07_Wed_LiteSpeed_Full.BKP',
@with = 'move "O1_SITEDB" to "S:\OSiteDB_Data.mdf"',
@with = 'move "O1_SITEDB_Log" to "Some dev null location??"

有没有办法可以将 LDF 位置指定为某个空位置? 我不想要 LDF,或者,有没有办法告诉它根本不获取 ldf?

I'm in an issue where I don't have enough space to accomodate my MDF and LDF files from a LiteSpeed backup we had done.

I've come up with the following sproc:

exec master.dbo.xp_restore_database

@database = 'OSiteDB',
@filename = 'L:\OSiteDB_2009_01_07_Wed_LiteSpeed_Full.BKP',
@with = 'move "O1_SITEDB" to "S:\OSiteDB_Data.mdf"',
@with = 'move "O1_SITEDB_Log" to "Some dev null location??"

Is there a way I can specify the LDF location to some null location? I don't want the LDF, alternatively, is there a way I can tell it not to fetch the ldf at all?

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

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

发布评论

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

评论(3

何以畏孤独 2024-07-19 23:08:07

您需要恢复 LDF 和 MDF。 日志是数据库不可或缺的一部分:没有它,它就不是 RDBMS 意义上的“数据库”。

作为紧急情况,您需要插入外部驱动器或恢复到 NTFS 压缩文件夹。 然后,您可以收缩数据库文件。 然而,这只是一个快速修复方法,让您能够正确地进行操作。

You need to restore the LDF as well as the MDF. The log is an integral part of the database: it's not a "database" in the RDBMS sense without it.

As an emergency, you need to plug in an external drive or restore to an NTFS compressed folder. Then, you can shrink the database files. However, this is only a quick fix and getw you going so you can do it properly.

趁年轻赶紧闹 2024-07-19 23:08:07

您是否看过“WITH NORECOVERY”选项?

特别是,我相信您可以使用 WWITH NOCEOVERY 恢复数据库,然后使用 RECOVERY 恢复 LOG (没有日志文件)。

http://msdn.microsoft.com/en-us/library/ms191253。 ASPX

Have you looked at the WITH NORECOVERY options?

In particular, I believe you can restore the database WWITH NOCEOVERY and then the LOG WITH RECOVERY (with no log file).

http://msdn.microsoft.com/en-us/library/ms191253.aspx

琉璃梦幻 2024-07-19 23:08:07

我认为您无法避免恢复 LDF 文件。 但是,正如您所提到的,您也许可以将其恢复到临时位置。

来自 这里

--Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = ‘L:\OSiteDB_2009_01_07_Wed_LiteSpeed_Full.BKP’
GO

--Step 2: Use the values in the LogicalName Column in following Step.
—-Make Database to single user Mode
ALTER DATABASE OSiteDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE

—-Restore Database
RESTORE DATABASE OSiteDB
FROM DISK = ‘L:\OSiteDB_2009_01_07_Wed_LiteSpeed_Full.BKP’
WITH 
  MOVE ‘O1_SITEDB’ TO ‘S:\OSiteDB_Data.mdf’,
  MOVE ‘O1_SITEDB_Log’ TO ‘C:\OSiteDB_Log.ldf’

/*If there is no error in statement before database will be in multiuser mode.
If error occurs please execute following command it will convert
database in multi user.*/
ALTER DATABASE OSiteDB SET MULTI_USER
GO

更改LDF文件的目标并看看会发生什么。

I don't think you can avoid restoring the LDF file. But, as you mentioned, you might be able to restore it into a temporary location.

From here:

--Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = ‘L:\OSiteDB_2009_01_07_Wed_LiteSpeed_Full.BKP’
GO

--Step 2: Use the values in the LogicalName Column in following Step.
—-Make Database to single user Mode
ALTER DATABASE OSiteDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE

—-Restore Database
RESTORE DATABASE OSiteDB
FROM DISK = ‘L:\OSiteDB_2009_01_07_Wed_LiteSpeed_Full.BKP’
WITH 
  MOVE ‘O1_SITEDB’ TO ‘S:\OSiteDB_Data.mdf’,
  MOVE ‘O1_SITEDB_Log’ TO ‘C:\OSiteDB_Log.ldf’

/*If there is no error in statement before database will be in multiuser mode.
If error occurs please execute following command it will convert
database in multi user.*/
ALTER DATABASE OSiteDB SET MULTI_USER
GO

Change the destination of the LDF file and see what happens.

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