Difference between revisions of "SQWareProduction:mssql:lib:sqwmsq RestoreDatabase.lib"
m (Updated by Expdbtools) |
m (Updated by Expdbtools) |
||
Line 1: | Line 1: | ||
− | + | shell functions librairy $gvsqw_MssBin/../lib/sqwmsq_RestoreDatabase.lib:<br> | |
− | + | {{SQWareProduction_sqwmsq_RestoreDatabase.lib_presentation}} | |
<br> | <br> | ||
+ | Functions explanation: | ||
+ | <pre> | ||
cat $gvsqw_TmpFile.fic|grep dump|grep "${lfsqw_DatabaseSource}_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]_"|awk '{print $NF}'> $gvsqw_TmpFile | cat $gvsqw_TmpFile.fic|grep dump|grep "${lfsqw_DatabaseSource}_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]_"|awk '{print $NF}'> $gvsqw_TmpFile | ||
− | echo "No backup of ${lfsqw_DatabaseSource} found on | + | echo "exec xp_cmdshell 'dir $lvsqw_BackupPath/${lfsqw_DatabaseSource}*.dump'" >$gvsqw_TmpFile |
+ | echo "No backup of ${lfsqw_DatabaseSource} found on $lvsqw_BackupPath" |tee -a $gvsqw_TmpFile.mail | ||
echo "No file like ${lfsqw_DatabaseSource}_$lvsqw_BckDate_*\${TYPE}*.dump\n" |tee -a $gvsqw_TmpFile.mail | echo "No file like ${lfsqw_DatabaseSource}_$lvsqw_BckDate_*\${TYPE}*.dump\n" |tee -a $gvsqw_TmpFile.mail | ||
echo "No file like ${lfsqw_DatabaseSource}_\$lvsqw_BckDate_*\${TYPE}*.dump\n" |tee -a $gvsqw_TmpFile.mail | echo "No file like ${lfsqw_DatabaseSource}_\$lvsqw_BckDate_*\${TYPE}*.dump\n" |tee -a $gvsqw_TmpFile.mail | ||
echo "search file $lfsqw_FileName" | echo "search file $lfsqw_FileName" | ||
− | |||
FIC=`cat $gvsqw_TmpFile|grep "${lfsqw_DatabaseSource}_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]_fstripe1_" | tail -1 | sed 's/fstripe..*/fstripe/'` | FIC=`cat $gvsqw_TmpFile|grep "${lfsqw_DatabaseSource}_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]_fstripe1_" | tail -1 | sed 's/fstripe..*/fstripe/'` | ||
FIC=`cat $gvsqw_TmpFile|grep "${lfsqw_DatabaseSource}_${lvsqw_BckDate}_fstripe1_" | tail -1 | sed 's/fstripe..*/fstripe/'` | FIC=`cat $gvsqw_TmpFile|grep "${lfsqw_DatabaseSource}_${lvsqw_BckDate}_fstripe1_" | tail -1 | sed 's/fstripe..*/fstripe/'` | ||
FIC=`cat $gvsqw_TmpFile|grep $lfsqw_FileName | tail -1 | sed 's/fstripe..*/fstripe/'` | FIC=`cat $gvsqw_TmpFile|grep $lfsqw_FileName | tail -1 | sed 's/fstripe..*/fstripe/'` | ||
− | gfsqw_ExecSql $gvsqw_TmpFile > $gvsqw_TmpFile.fic | + | gfsqw_ConvertBackslashToSlash $lvsqw_BackupPath|read lvsqw_BackupPath |
− | if [ $grep -c ${lfsqw_DatabaseSource} $gvsqw_TmpFile -ne 0 ] | + | gfsqw_ConvertSlashToBackslash $gvsqw_TmpFile |
+ | gfsqw_ConvertSlashToBackslash $gvsqw_TmpFile.sql | ||
+ | gfsqw_EndMailError 34 "Fail to retrieve BackupDirectory !" | ||
+ | gfsqw_ExecSql $gvsqw_TmpFile.sql | ||
+ | gfsqw_ExecSql $gvsqw_TmpFile.sql >$gvsqw_TmpFile | ||
+ | gfsqw_ExecXpCmdShell $gvsqw_TmpFile > $gvsqw_TmpFile.fic | ||
+ | if [ $grep -c ${lfsqw_DatabaseSource} $gvsqw_TmpFile => -ne 0 ] | ||
if [ ! -z "$lfsqw_FileName" ] | if [ ! -z "$lfsqw_FileName" ] | ||
− | + | lfsqw_BackupPath => | |
− | lfsqw_GenerateSql | + | lfsqw_GenerateSql => |
− | + | lfsqw_ListBck => | |
− | lfsqw_ListBck | + | lfsqw_RsyncOrphans => |
− | + | lvsqw_BackupPathBackslash=$gfsqw_ConvertSlashToBackslash $lvsqw_BackupPath => | |
− | + | </pre> | |
− | |||
<br> | <br> | ||
{{SQWareProductionSurchargeLib|mssql|Mss|sqwmsq_RestoreDatabase.lib}} | {{SQWareProductionSurchargeLib|mssql|Mss|sqwmsq_RestoreDatabase.lib}} | ||
<br> | <br> |
Revision as of 23:26, 15 December 2010
shell functions librairy $gvsqw_MssBin/../lib/sqwmsq_RestoreDatabase.lib:
lib for sqwmsq_RestoreDatabase.ksh
Functions explanation:
cat $gvsqw_TmpFile.fic|grep dump|grep "${lfsqw_DatabaseSource}_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]_"|awk '{print $NF}'> $gvsqw_TmpFile echo "exec xp_cmdshell 'dir $lvsqw_BackupPath/${lfsqw_DatabaseSource}*.dump'" >$gvsqw_TmpFile echo "No backup of ${lfsqw_DatabaseSource} found on $lvsqw_BackupPath" |tee -a $gvsqw_TmpFile.mail echo "No file like ${lfsqw_DatabaseSource}_$lvsqw_BckDate_*\${TYPE}*.dump\n" |tee -a $gvsqw_TmpFile.mail echo "No file like ${lfsqw_DatabaseSource}_\$lvsqw_BckDate_*\${TYPE}*.dump\n" |tee -a $gvsqw_TmpFile.mail echo "search file $lfsqw_FileName" FIC=`cat $gvsqw_TmpFile|grep "${lfsqw_DatabaseSource}_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]_fstripe1_" | tail -1 | sed 's/fstripe..*/fstripe/'` FIC=`cat $gvsqw_TmpFile|grep "${lfsqw_DatabaseSource}_${lvsqw_BckDate}_fstripe1_" | tail -1 | sed 's/fstripe..*/fstripe/'` FIC=`cat $gvsqw_TmpFile|grep $lfsqw_FileName | tail -1 | sed 's/fstripe..*/fstripe/'` gfsqw_ConvertBackslashToSlash $lvsqw_BackupPath|read lvsqw_BackupPath gfsqw_ConvertSlashToBackslash $gvsqw_TmpFile gfsqw_ConvertSlashToBackslash $gvsqw_TmpFile.sql gfsqw_EndMailError 34 "Fail to retrieve BackupDirectory !" gfsqw_ExecSql $gvsqw_TmpFile.sql gfsqw_ExecSql $gvsqw_TmpFile.sql >$gvsqw_TmpFile gfsqw_ExecXpCmdShell $gvsqw_TmpFile > $gvsqw_TmpFile.fic if [ $grep -c ${lfsqw_DatabaseSource} $gvsqw_TmpFile => -ne 0 ] if [ ! -z "$lfsqw_FileName" ] lfsqw_BackupPath => lfsqw_GenerateSql => lfsqw_ListBck => lfsqw_RsyncOrphans => lvsqw_BackupPathBackslash=$gfsqw_ConvertSlashToBackslash $lvsqw_BackupPath =>