Solved

Restoring filegroups in MS SQL 2008

Posted on 2011-03-24
12
981 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
Comment Utility
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
Comment Utility
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
Comment Utility
Check files in this particular backup:

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

Author Comment

by:wilcosw
Comment Utility
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
Comment Utility
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
Comment Utility
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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 1

Author Comment

by:wilcosw
Comment Utility
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
Comment Utility
Can you post command you use to restore which gives you error?
0
 
LVL 1

Author Comment

by:wilcosw
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
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…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now