Using FILEGROUP backup one can backup all the data files within the SQL Server FILEGROUP individually. While backing up the database you can specify whole of FILEGROUP (i.e., PRIMARY or SECONDARY) instead of specifying each database file individually within the FILEGROUP.
USE [master]
GO
CREATE DATABASE [MyTechMantra]
CONTAINMENT = PARTIAL
ON PRIMARY
(
NAME = N'MyTechMantra',
FILENAME = N'F:\MSSQL\DATA\MyTechMantra.mdf',
SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB
),
(
NAME = N'MyTechMantra_Data2',
FILENAME = N'F:\MSSQL\DATA\MyTechMantra_Data2.ndf',
SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB
),
FILEGROUP [ReadOnly]
(
NAME = N'MyTechMantra_ReadOnly',
FILENAME = N'F:\MSSQL\DATA\MyTechMantra_ReadOnly.ndf',
SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB
)
LOG ON
(
NAME = N'MyTechMantra_log',
FILENAME = N'F:\MSSQL\DATA\MyTechMantra_log.ldf',
SIZE = 2048KB , MAXSIZE = 2048GB , FILEGROWTH = 10%
)
GO
In this example we will backup Read Only Data File which is available in Secondary File Group.
BACKUP DATABASE [MyTechMantra]
FILEGROUP = N'ReadOnly'
TO DISK = N'C:\DBBackups\MyTechMantra_MyTechMantra_ReadOnly.bck'
WITH NOFORMAT, NOINIT, COMPRESSION, STATS = 25
GO


Not a member yet? Register now
Are you a member? Login now