0

我已经对SampleDB数据库进行了文件组备份,我想将它恢复到另一个现有的空数据库RestoreDB。我能够恢复完整备份,但在恢复文件组备份时遇到问题。

这是我到目前为止所尝试的。

RESTORE DATABASE RestoreDB
FROM DISK = 'D:\Sample\SampleDB_FileGroup.bak'
WITH    
    REPLACE,    -- Overwrite DB - if one exists
    NORECOVERY, -- Use if DIFFs / T/Logs to recover
--  RECOVERY,   -- Use if NO more files to recover, database will be set ready to use
    STATS = 10, -- Show progress (every 10%)
MOVE 'SampleDB' TO 'D:\Sample\RestoreDB\RestoreDB.mdf', 
MOVE 'SampleDB_2' TO 'D:\Sample\RestoreDB\RestoreDB_2.ndf',
MOVE 'SampleDB_log' TO 'D:\Sample\RestoreDB\RestoreDB_log.ldf'

使用上面的代码,我能够恢复完整备份,但无法恢复文件组备份。

关于如何实现这一目标的任何想法?

4

2 回答 2

0

使用关键字 PARTIAL 恢复 PRIMARY 文件组和您需要的所有文件组,然后恢复文件组。

RESTORE DATABASE RestoreDB
FROM DISK = 'D:\Sample\SampleDB_FileGroup.bak'
WITH    
    REPLACE,    -- Overwrite DB - if one exists
    NORECOVERY, -- Use if DIFFs / T/Logs to recover
    STATS = 10, -- Show progress (every 10%)
    MOVE 'SampleDB' TO 'D:\Sample\RestoreDB\RestoreDB.mdf', 
    MOVE 'SampleDB_2' TO 'D:\Sample\RestoreDB\RestoreDB_2.ndf',
    MOVE 'SampleDB_log' TO 'D:\Sample\RestoreDB\RestoreDB_log.ldf',
    PARTIAL
于 2013-11-13T12:18:44.860 回答
0

我也试过了:

CREATE DATABASE [SampleDB] ON  PRIMARY 
( NAME = N'SampleDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDB.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB ), 
 FILEGROUP [FG2] 
( NAME = N'F2', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\F2.ndf' , SIZE = 3072KB , FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'SampleDB_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDB_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)
GO

BACKUP DATABASE SampleDB
TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup1.bak' WITH INIT

BACKUP DATABASE SampleDB FILEGROUP = N'FG2'
TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup2.bak'

RESTORE DATABASE RestoreDB
FILEGROUP = N'PRIMARY'
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup1.bak'
WITH 
    MOVE N'SampleDB' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\RestoreDB.mdf',
    MOVE N'SampleDB_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\RestoreDB_log.ldf'    

RESTORE DATABASE RestoreDB
FILEGROUP = N'FG2'
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup2.bak'
WITH 
    MOVE N'F2' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\RestoreDB2.ndf'

但我得到一个错误:

提供的备份与数据库不在同一恢复路径上,并且不适合用于在线文件还原。

我不知道,因为从来不需要这样做,但不可能移动它,Paul Randal 在这里回答这个问题:http ://www.sqlservercentral.com/Forums/Topic412470-357-1.aspx

于 2013-11-13T12:50:44.623 回答