sql tranlog backup with exlude variable
I have wrote a script that will run and populate a env var with the databases that are in simple mode :
@echo off
sqlcmd -S server\instance -Q "set nocount on; select name from sys.databases where recovery_model!=1" -W -h -1 -o c:\U...\...\Desktop\sql.txt
setlocal EnableDelayedExpansion
set "txt="
set input=c:\....\......\Desktop\sql.txt
for /f "delims=" %%a in (%input%) do (
set "txt=!txt!%%a,"
)
set "txt=!txt:~0,-1!"
>new.txt echo !txt!
echo %txt%
setx NB_SQL_DATABASE_EXCLUDE %txt%
echo %NB_SQL_DATABASE_EXCLUDE%
and i have the following script for a tranlog backup:
BATCHSIZE 3
OPERATION BACKUP
DATABASE $ALL
SQLHOST "sqlhost"
SQLINSTANCE "SQL2008R2"
NBSERVER "master01"
MAXTRANSFERSIZE 6
BLOCKSIZE 7
OBJECTTYPE TRXLOG
NUMBUFS 2
ENDOPER TRUE
But when the policy runs i still see it running the excluded databases by the enviornment variable.
any thoughts?
I ran sqlcmd you have written above and got the list of system DBs which should be excluded (having simple recovery model) in sql.txt. then added one of the user database i wanted to exclude in sql.txt file. then ran the script you have created. i verified that User environment variable NB_SQL_DATABASE_EXCLUDE got set properly but databases are ',' seperated then i changed the seperator to ';' (which NetBackup for MSSQL agent expects).
Then i reopened the MSSQL agent GUI and ran the same batch file as you have mentioned above (obviously after modifying the SQLHOST, SQL instance and NBSERVER). It is excluding the databases specified in NB_SQL_DATABASE_EXCLUDE User environment variable.
I didn't specify NB_SQL_DATABASE_EXCLUDE in system environment variable.
I ran above test with administrator. I also tried with another user as well and everything is working as expected.
I looked at the dbclient logs you have provided and it has excluded the 'JAMS' database for trxlog backup.
Can you manually specify User environment variable NB_SQL_DATABASE_EXCLUDE and database names with ',' seperated and try the backup?