Difference between revisions of "Template:SQWareProduction sqwmsq GlobalVar.cfg content"
m (Updated by BatchUser) |
m (Updated by BatchUser) |
||
(31 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
File content: | File content: | ||
<pre> | <pre> | ||
− | #!/bin/ | + | #!/bin/bash |
################################################################### | ################################################################### | ||
# SQWareProduction for Mssql module of dbSQWare | # SQWareProduction for Mssql module of dbSQWare | ||
Line 17: | Line 17: | ||
################################################################### | ################################################################### | ||
## @Synopsis Global var for Mssql | ## @Synopsis Global var for Mssql | ||
− | ## @Copyright Copyright | + | ## @Copyright Copyright 2007-2025, dbSQWare (www.dbsqware.com) |
#global | #global | ||
− | export gvsqw_MssqlPassFile=$gvsqw_DistPasswdFile | + | export gvsqw_SqwVersionDbms=2025.02 |
+ | |||
+ | #Check if we are in local on SQL Linux or distant connection with FreeTds | ||
+ | if [ "$(uname -s)" = "Linux" ] | ||
+ | then | ||
+ | if [ "$(type sqlcmd 2>&1 >/dev/null;echo $?)" = "0" ] | ||
+ | then | ||
+ | export gvsqw_ExecEnvType='SqlCmd' | ||
+ | export gvsqw_CommandPathVersionList="$gvsqw_CommandPathVersionList sqlcmd;-?" | ||
+ | elif [ "$(type tsql 2>&1 >/dev/null;echo $?)" = "0" ] | ||
+ | then | ||
+ | export gvsqw_ExecEnvType='FreeTds' | ||
+ | export gvsqw_CommandPathVersionList="$gvsqw_CommandPathVersionList tsql;-C" | ||
+ | else | ||
+ | echo $gvsqw_EchoOpt "Can't find if env is 'SqlCmd' or 'FreeTds' !" | ||
+ | export gvsqw_ExecEnvType='LinuxKO' | ||
+ | fi | ||
+ | else | ||
+ | echo $gvsqw_EchoOpt "Script need to be executed on Linux !" | ||
+ | export gvsqw_ExecEnvType='NoLinuxKO' | ||
+ | fi | ||
+ | |||
+ | if [ "$gvsqw_DistPasswdFile" != "" ] | ||
+ | then | ||
+ | export gvsqw_MssqlPassFile=$gvsqw_DistPasswdFile | ||
+ | else | ||
+ | export gvsqw_DistPasswdFile="$HOME/.passwd_mssql" | ||
+ | fi | ||
export gvsqw_MssqlSaUser='sa' | export gvsqw_MssqlSaUser='sa' | ||
export gvsqw_RootAdmin='$HOME/admin/${lvsqw_InstanceParam}' | export gvsqw_RootAdmin='$HOME/admin/${lvsqw_InstanceParam}' | ||
export gvsqw_RootAdminDisable='$HOME' | export gvsqw_RootAdminDisable='$HOME' | ||
export gvsqw_RootCfg='$gvsqw_RootAdmin/sqwConfig' | export gvsqw_RootCfg='$gvsqw_RootAdmin/sqwConfig' | ||
− | export gvsqw_WhereClauseGenDatabaseList="and name not like 'tempdb%'" | + | export gvsqw_WhereClauseGenDatabaseList="and name not like 'tempdb%' and name not like 'ReportServer%TempDb'" |
export gvsqw_DbAlias='$lvsqw_InstanceParam' | export gvsqw_DbAlias='$lvsqw_InstanceParam' | ||
export gvsqw_SuppAlert=90 | export gvsqw_SuppAlert=90 | ||
Line 31: | Line 58: | ||
export gvsqw_MsSqlErrorMsg='^Msg [0-9][0-9]*, Level 0, State 1|^Server ..*, Line 1|@@rowcount' | export gvsqw_MsSqlErrorMsg='^Msg [0-9][0-9]*, Level 0, State 1|^Server ..*, Line 1|@@rowcount' | ||
export gvsqw_XpCmdShellWaitTimeOut=300 | export gvsqw_XpCmdShellWaitTimeOut=300 | ||
+ | #to avoid "Cannot resolve collation conflict for column ..." | ||
+ | export gvsqw_Collate='Latin1_General_CI_AI' | ||
#for backup scripts | #for backup scripts | ||
Line 40: | Line 69: | ||
export gvsqw_NbMaxStripe=5 | export gvsqw_NbMaxStripe=5 | ||
export gvsqw_BackupStatSize=10 | export gvsqw_BackupStatSize=10 | ||
+ | if [ "$gvsqw_ExecEnvType" = 'SqlCmd' ] | ||
+ | then | ||
+ | ##Specific for Linux env | ||
+ | export gvsqw_LinuxBackupPath='/mssql_backups/${lvsqw_InstanceParam}' | ||
+ | export gvsqw_SqlCmdOpt='-C' | ||
+ | fi | ||
#for Rebuild index scripts | #for Rebuild index scripts | ||
Line 47: | Line 82: | ||
export gvsqw_SetOptionsRebuild='set ansi_defaults, concat_null_yields_null on | export gvsqw_SetOptionsRebuild='set ansi_defaults, concat_null_yields_null on | ||
go' | go' | ||
+ | export gvsqw_RebuildType='index' #Rebuild type, 'all' for tables, 'index' for indexes | ||
+ | export gvsqw_MinRatioReb=30 #Min avg_fragmentation_in_percent before rebuild | ||
+ | export gvsqw_MinRatioRgz=10 #Min avg_fragmentation_in_percent before reorganize | ||
+ | export gvsqw_SizeMinIndexRebuild=1 #Min size of index in Mb to take into account | ||
+ | export gvsqw_SizeMaxIndexRebuild=50000 #Max size of index in Mb to take into account | ||
#for update statistics scripts | #for update statistics scripts | ||
Line 68: | Line 108: | ||
export gvsqw_BackupsIndicatorsDays=2 | export gvsqw_BackupsIndicatorsDays=2 | ||
export gvsqw_ExcludeDatabaseStatus="'OFFLINE','RESTORING'" | export gvsqw_ExcludeDatabaseStatus="'OFFLINE','RESTORING'" | ||
+ | export gvsqw_GenExcludeDatabasesObjects="^master$|^msdb$|^model$|^ReportServer" | ||
+ | export gvsqw_GenExcludeDatabasesObjectsExtra="" | ||
+ | #Remove or replace extra characters like E with accent ! | ||
+ | export gvsqw_StringReplaceSch="tr -d '\015'|tr '\311' 'E'" | ||
+ | export gvsqw_UserTypeList="'SQL_LOGIN','WINDOWS_LOGIN'" | ||
##Globaly forcing return code for scripts | ##Globaly forcing return code for scripts |
Revision as of 23:28, 2 March 2025
File content:
#!/bin/bash ################################################################### # SQWareProduction for Mssql module of dbSQWare # # dbSQWare is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # CGU/CGA for more details. # # You should have received a copy of the CGU/CGA # along with this program. If not, see <http://www.dbsqware.com/licenses/>. # # For information : contact@dbsqware.com or www.dbsqware.com ################################################################### ## @Synopsis Global var for Mssql ## @Copyright Copyright 2007-2025, dbSQWare (www.dbsqware.com) #global export gvsqw_SqwVersionDbms=2025.02 #Check if we are in local on SQL Linux or distant connection with FreeTds if [ "$(uname -s)" = "Linux" ] then if [ "$(type sqlcmd 2>&1 >/dev/null;echo $?)" = "0" ] then export gvsqw_ExecEnvType='SqlCmd' export gvsqw_CommandPathVersionList="$gvsqw_CommandPathVersionList sqlcmd;-?" elif [ "$(type tsql 2>&1 >/dev/null;echo $?)" = "0" ] then export gvsqw_ExecEnvType='FreeTds' export gvsqw_CommandPathVersionList="$gvsqw_CommandPathVersionList tsql;-C" else echo $gvsqw_EchoOpt "Can't find if env is 'SqlCmd' or 'FreeTds' !" export gvsqw_ExecEnvType='LinuxKO' fi else echo $gvsqw_EchoOpt "Script need to be executed on Linux !" export gvsqw_ExecEnvType='NoLinuxKO' fi if [ "$gvsqw_DistPasswdFile" != "" ] then export gvsqw_MssqlPassFile=$gvsqw_DistPasswdFile else export gvsqw_DistPasswdFile="$HOME/.passwd_mssql" fi export gvsqw_MssqlSaUser='sa' export gvsqw_RootAdmin='$HOME/admin/${lvsqw_InstanceParam}' export gvsqw_RootAdminDisable='$HOME' export gvsqw_RootCfg='$gvsqw_RootAdmin/sqwConfig' export gvsqw_WhereClauseGenDatabaseList="and name not like 'tempdb%' and name not like 'ReportServer%TempDb'" export gvsqw_DbAlias='$lvsqw_InstanceParam' export gvsqw_SuppAlert=90 #export gvsqw_MsSqlErrorMsg='^Msg 3014, Level 0, State 1|^Msg 3211, Level 0, State 1|^Msg 4035, Level 0, State 1|^Server ..*, Line 1|@@rowcount' export gvsqw_MsSqlErrorMsg='^Msg [0-9][0-9]*, Level 0, State 1|^Server ..*, Line 1|@@rowcount' export gvsqw_XpCmdShellWaitTimeOut=300 #to avoid "Cannot resolve collation conflict for column ..." export gvsqw_Collate='Latin1_General_CI_AI' #for backup scripts export gvsqw_NbThreadBackup=4 export gvsqw_DefAGR_Backup=5 export gvsqw_DefAGE_Backup=20 export gvsqw_BackupNbGeneration=2 export gvsqw_SizeMaxStripe=40000 export gvsqw_NbMaxStripe=5 export gvsqw_BackupStatSize=10 if [ "$gvsqw_ExecEnvType" = 'SqlCmd' ] then ##Specific for Linux env export gvsqw_LinuxBackupPath='/mssql_backups/${lvsqw_InstanceParam}' export gvsqw_SqlCmdOpt='-C' fi #for Rebuild index scripts export gvsqw_NbThreadRebuild=4 export gvsqw_DefAGR_Rebuild=5 export gvsqw_DefAGE_Rebuild=20 export gvsqw_SetOptionsRebuild='set ansi_defaults, concat_null_yields_null on go' export gvsqw_RebuildType='index' #Rebuild type, 'all' for tables, 'index' for indexes export gvsqw_MinRatioReb=30 #Min avg_fragmentation_in_percent before rebuild export gvsqw_MinRatioRgz=10 #Min avg_fragmentation_in_percent before reorganize export gvsqw_SizeMinIndexRebuild=1 #Min size of index in Mb to take into account export gvsqw_SizeMaxIndexRebuild=50000 #Max size of index in Mb to take into account #for update statistics scripts export gvsqw_NbThreadStatistics=4 export gvsqw_DefAGR_Statistics=5 export gvsqw_DefAGE_Statistics=20 #for restore scripts export gvsqw_NbThreadRestore=4 export gvsqw_DefAGR_Restore=5 export gvsqw_DefAGE_Restore=20 export gvsqw_RestoreStatSize=5 #for checkdb scripts export gvsqw_NbThreadCheckdb=4 export gvsqw_DefAGR_Checkdb=5 export gvsqw_DefAGE_Checkdb=20 #for indicators export gvsqw_SizeMinTableIndicators=10 export gvsqw_BackupsIndicatorsDays=2 export gvsqw_ExcludeDatabaseStatus="'OFFLINE','RESTORING'" export gvsqw_GenExcludeDatabasesObjects="^master$|^msdb$|^model$|^ReportServer" export gvsqw_GenExcludeDatabasesObjectsExtra="" #Remove or replace extra characters like E with accent ! export gvsqw_StringReplaceSch="tr -d '\015'|tr '\311' 'E'" export gvsqw_UserTypeList="'SQL_LOGIN','WINDOWS_LOGIN'" ##Globaly forcing return code for scripts #export gvsqw_ForcedReturnCodeScript_sqwmsq_BackupAllDatabases=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_BackupDatabase=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_CheckdbAllDatabases=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_CheckdbDatabase=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_CheckIndicators=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_GatherIndicators=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_ParallelRun=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_RebuildIndexAllDatabases=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_RebuildIndexDatabase=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_RestoreAllDatabases=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_RestoreDatabase=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_RotateErrorLog=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_StatisticsAllDatabases=0 #export gvsqw_ForcedReturnCodeScript_sqwmsq_StatisticsDatabase=0