Feb
26
2013

Using EXCLUDE in NetBackup .bch script –SQL Server database backups

I was searching for a solution to exclude specific database from Symantec NetBackup .bch script for SQL Server database backups, there are two ways to excluded databases,

 

1. By using EXCLUDE parameter

As per admin guide,

Name of a database to exclude when DATABASE $ALL is specified in a batch operation EXCLUDE can be used in a batch file only if DATABASE $ALL is used.

 

Following is sample .bch file with some example of exclude parameters,

 

OPERATION BACKUP

DATABASE $ALL

EXCLUDE “test”

EXCLUDE “model”

EXCLUDE “AdventureWorks”

SQLHOST “SQLServerName”

SQLINSTANCE “SQLInstanceName”

NBSERVER “MASTER”

MAXTRANSFERSIZE 6

BLOCKSIZE 7

BROWSECLIENT “SQLServerName”    #Optional parameter

POLICY SQLBackupPolicyNAme    #Optional parameter

OBJECTTYPE TRXLOG        #Use only for t-log backup with truncate

NUMBUFS 2

ENDOPER TRUE

 

2. By declaring an Environment Variable

As per admin guide,

To exclude SQL Server instances on your host from backup, create the Windows environmental variable NB_SQL_INSTANCE_EXCLUDE. Specify a list of instances names that you want to exclude. The list should consist of one or more names that are separated by semi-colons. For example,

 

use the following value to indicate that you want to exclude the default SQL Server instance and the instance named ABC-PRODUCTS from backup:

#DEFAULT#;ABC-PRODUCTS;

 

Note that the default SQL Server instance for the local host is designated as #default#

 

You can also exclude individual databases from backup by creating a Windows environmental variable NB_SQL_DATABASE_EXCLUDE. For the value of the variable, specify a list of database names.

 

For example, consider the following batch file:

SQLINSTANCE $ALL

OPERATION BACKUP

DATABASE $ALL

NBSERVER “BEARING”

MAXTRANSFERSIZE 6

BLOCKSIZE 7

NUMBUFS 2

ENDOPER TRUE

You can exclude the databases “master,” “accounting,” and “pubs” with the NB_SQL_DATABASE_EXCLUDE environmental variable. For the value of the variable, indicate the databases you want to exclude. Separate the database names with semi-colons as,

 

MASTER;ACCOUNTING;PUBS

 

The NB_SQL_DATABASE_EXCLUDE variable is applicable only for a batch file that has DATABASE $ALL. It performs the same function as the keyword and value pair EXCLUDE <database>. If both variables are used, they augment each other to determine which databases to exclude.

 

Useful references:

http://www.symantec.com/connect/forums/nbsqldatabaseexclude-not-work

www.symantec.com/ (Search for MSSQL Administrator Guide for the version of NetBackup you have in your systems)

Download PDF

About the Author: Nitin G

Indian born, trekker, biker, photographer, lover of monsoons. I've been working full time with SQL Server since year 2005 and blogs to post the content aquired during my research on new topics or fixing issues faced by me as a DBA while working in different kind of projects, hope some of my posts may helps others in SQLDBA community. Everything you read on my blog is my own personal opinion and any code is provided "AS-IS" with no warranties!

2 Comments + Add Comment

  • how to exclude DB that are named like :

    DIV23!PRJ=AW0321srv!DB=ISHTALM

    • Hi George, putting DB name in double quotes for e.g. EXCLUDE “DIV23!PRJ=AW0321srv!DB=ISHTALM”

Leave a comment

Subscribe to this blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 174 other subscribers

Translate this blog!

EnglishFrenchGermanItalianPortugueseRussianSpanish

Calender

May 2019
M T W T F S S
« Nov    
 12345
6789101112
13141516171819
20212223242526
2728293031  

View Post by Categories

%d bloggers like this: