Solved

Restoring filegroups in MS SQL 2008

Posted on 2011-03-24
12
1,010 Views
Last Modified: 2012-05-11
Hi,

I would like to know how to restore specific Filegroups from a a filegroup backup file in sql server 2008.

i have followed books online's tutorial step by step, yet nothing seems to work.

This is the exception i cannot seem to get figured out...

File 'Tester2' was not backed up in file 1 on device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Primary.bak'. The file cannot be restored from this backup set.
RESTORE DATABASE is terminating abnormally. (.Net SqlClient Data Provider)


Any help would be a life saver,

Thank you in advance.
0
Comment
Question by:wilcosw
  • 5
  • 5
  • 2
12 Comments
 
LVL 8

Expert Comment

by:avirups
ID: 35205714
Please run the following and post the result here:

RESTORE HEADERONLY
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Primary.bak'
WITH NOUNLOAD;
GO
0
 
LVL 1

Author Comment

by:wilcosw
ID: 35205874
Hi avirups,

After i ran the above query, this is the result i got...

Please see the attached file.

 QueryResult.xlsx
0
 
LVL 14

Expert Comment

by:Daniel_PL
ID: 35206513
Check files in this particular backup:

RESTORE FILELISTONLY
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Primary.bak'
0
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
LVL 1

Author Comment

by:wilcosw
ID: 35206623
Hi,

I 'm not exactly sure what the above query is supposed to retrieve ?

Please check my original question .
0
 
LVL 14

Expert Comment

by:Daniel_PL
ID: 35206696
I would like you to assure whether your file 'Tester2' is in the backup, look for LogicalName column.
Above query retrieves file list contained in a backup.
0
 
LVL 8

Expert Comment

by:avirups
ID: 35207709
The result you posted confirms that the backup was a file type backup. If you run

RESTORE FILELISTONLY
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Primary.bak'

as rightfully suggested by Daniel_PL, you will get the details of what files are backed up within this backup file and whether or not Tester2 is a part of this backup. If the error you are getting is to be believed then you shall not find the Tester2 in your result of the above query.

In that case you'll have to find out the backup file that contains Tester2 in order to restore it.

Hope this helps.
0
 
LVL 1

Author Comment

by:wilcosw
ID: 35213207
Hi,

Sorry for my delayed reply.

I have attached the results for the above mentioned query, and the file tester2 does appear in the retrieved results. QueryResult-FileListOnly.xlsx
0
 
LVL 14

Expert Comment

by:Daniel_PL
ID: 35213218
Can you post command you use to restore which gives you error?
0
 
LVL 1

Author Comment

by:wilcosw
ID: 35213241
Hi,

I didn't use t-sql, i used ssms for both creating the backup and restoring the backup.

Would using t-sql result in possible different behaviour?
0
 
LVL 14

Accepted Solution

by:
Daniel_PL earned 500 total points
ID: 35213595
SSMS seems to don't allow restore single file/filegroup from full backup. You can script your actions by choosing all options and then using the script button at the top of the window.

In your case you have full backup, you can restore your Tester2 filegroup by executing command:
 
RESTORE DATABASE Tester 
FILEGROUP = N'Filegroup1' 
FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Primary.bak' WITH STATS = 10
GO

Open in new window


You can execute only file/filegroup backup (backup will only contain this file/filegroup):
 
BACKUP DATABASE Tester 
FILEGROUP = N'Filegroup1' 
FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Filegroup1.bak'
GO

Open in new window


Enetrpise edition has great feature called piecemeal restore:
http://msdn.microsoft.com/en/library/ms177425%28v=sql.100%29.aspx
0
 
LVL 14

Expert Comment

by:Daniel_PL
ID: 35213622
Forgive me my forgetness :)
Please append ,RECOVERY to the end of first script:

RESTORE DATABASE Tester 
FILEGROUP = N'Filegroup1' 
FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Primary.bak' WITH STATS = 10, RECOVERY
GO

Open in new window

0
 
LVL 1

Author Comment

by:wilcosw
ID: 35214847
Hi,

Thank you very much for your help and advice.

I was able to restore my filegroups using the following set of commands.....(please see code insert at bottom).

One thing i noted was that i had to create a log backup after i made my last backup of a filegroup, before i was able to restore successfully.
This had to be done in order to sync the database log sequence numbers (lsn) after the individual filegroup restores.

 
RESTORE DATABASE Tester
   FILE = 'Tester',
   FILEGROUP = 'Primary'
   FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Primary.bak'
   WITH REPLACE
GO

RESTORE DATABASE Tester
   File = 'Tester2',
   Filegroup = 'Filegroup1'
   FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Filegroup1.bak'
   WITH NOUNLOAD, REPLACE, RECOVERY
GO


-- Apply the last transaction log backup.
RESTORE LOG Tester
   FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\Backup\Log_Full.bak'
   WITH REPLACE,RECOVERY
GO

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Help 27 67
Present Absent from working date rage 11 48
What can the "OPTION" in the GROUP help me in my query? 4 35
partitioning database after decade growth 8 54
This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question