Creating a filegroup backup
In this recipe, we will create a filegroup backup using the Backup-SqlDatabase
PowerShell cmdlet.
Getting ready
For testing purposes, let's create a small sample database called StudentDB
that contains a couple of filegroups called FG1
and FG2
. Each filegroup will have two data files, which will be saved in the C:\Temp
folder.
Open up SQL Server Management Studio and run the following script:
CREATE DATABASE [StudentDB] ON PRIMARY ( NAME = N'StudentDB', FILENAME = N'C:\Temp\StudentDB.mdf'), FILEGROUP [FG1] ( NAME = N'StudentData1', FILENAME = N'C:\Temp\StudentData1.ndf'), ( NAME = N'StudentData2', FILENAME = N'C:\Temp\StudentData2.ndf'), FILEGROUP [FG2] ( NAME = N'StudentData3', FILENAME = N'C:\Temp\StudentData3.ndf') LOG ON ( NAME = N'StudentDB_log', FILENAME = N'C:\Temp\StudentDB.ldf') GO
We will use this database to do our filegroup backup. Feel free to substitute this with a database that already exists in your instance which already has filegroups.