Restore filegroup to different database

2.5k views Asked by At

I have a SQL server database with 5 filegroups i want to backup 2 filegroups(one contains filestream)only and restore them to different existing database.

1

There are 1 answers

3
sepupic On BEST ANSWER

What you are asking about is Piecemeal Restores (SQL Server)

You can restore primary + all readwrite fg + any of readonly filegroups in you are in simple recovery model or you can restore primary + any other filegroup(s) if you are in full recovery model.

As the first filegroup to restore is always primary filegroup, it will replace your "different existing database" primary data file and log (in your restore command you should use with move that points to your existing mdf + log files) and every subsequent restore will overwrite other files, there will remain nothing from your "existing" database, so there is no sense to restore to a "different existing database": you will be able to bring online only the filegroups you are restored and the database will know nothing about remaining files of "existing database". So it's just the same as to restore to just another(non existing) database.

Here is the restore sequence example for primary + readonly fg in simple recovery model Example: Piecemeal Restore of Only Some Filegroups (Simple Recovery Model)

And here is the example for full recovery model Example: Piecemeal Restore of Only Some Filegroups (Full Recovery Model)