• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1103
  • Last Modified:

Restoring filegroups in MS SQL 2008

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
wilcosw
Asked:
wilcosw
  • 5
  • 5
  • 2
1 Solution
 
avirupsCommented:
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
 
wilcoswAuthor Commented:
Hi avirups,

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

Please see the attached file.

 QueryResult.xlsx
0
 
Daniel_PLDB Expert/ArchitectCommented:
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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
wilcoswAuthor Commented:
Hi,

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

Please check my original question .
0
 
Daniel_PLDB Expert/ArchitectCommented:
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
 
avirupsCommented:
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
 
wilcoswAuthor Commented:
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
 
Daniel_PLDB Expert/ArchitectCommented:
Can you post command you use to restore which gives you error?
0
 
wilcoswAuthor Commented:
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
 
Daniel_PLDB Expert/ArchitectCommented:
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
 
Daniel_PLDB Expert/ArchitectCommented:
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
 
wilcoswAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 5
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now