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 datafiles.
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.
How to do it...
Open the PowerShell console by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Import the
SQLPS
module as follows:#import...