Sample batch files Sample 12 - Using environment variables to exclude instances and databases from backup
NBSERVER "BEARING" MAXTRANSFERSIZE 6 BLOCKSIZE 7 NUMBUFS 2 ENDOPER TRUE
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, separated by semi-colons.
For example, use the value #DEFAULT#;ABC-PRODUCTS;
to indicate that you want to exclude the default SQL Server instance and the instance named ABC-PRODUCTS from backup. 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 by creating 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.
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/value pair EXCLUDE <database>. If both variables are used they augment each other to determine which databases to exclude.