Hi,
A customer of ours want's to take snapshots occassionaly (not to replace their DR, we have backups, AI and replication in place). We'll be implementing this on their test-environment first. I know we need to enable a quiet point before and disable it after taking the snapshot, and I know we can do that from the pre-freeze-script an pre-thaw-script.
Is anyone willing to share their script(s)? I'd like to learn :)
So far, I came up with something the script below, based on a KB entry.
-- Martin
LOGFILE=~/pre-freeze-script.log
DLC=/vcd/progress/dlc115
PATH=$DLC/bin:$PATH
WAITTIME=10
TIMEOUT=no
QUIETED=
proquiet_enable() {
DBNAME=$1
SECONDS=0
QUIETED="${QUIETED} $1"
echo "Requesting quiet point for $1..." >> ${LOGFILE}
proquiet ${DBNAME} enable >/dev/null 2>&1
ret=$?
while [ $ret -ne 0 ]
do
if [ $SECONDS -gt ${WAITTIME} ]
then
echo " timed out after ${SECONDS} seconds." >> ${LOGFILE}
TIMEOUT=yes
return
fi
sleep 5 >/dev/null 2>&1
echo " retrying..." >> ${LOGFILE}
proquiet ${DBNAME} enable >/dev/null 2>&1
ret=$?
done
}
for i in $*
do
proquiet_enable $i
if [ "${TIMEOUT}" == "yes" ]
then
break
fi
done
if [ "${TIMEOUT}" == "yes" ]
then
echo "One of the requests timed out, undo al quiet point requests" >> ${LOGFILE}
echo "Set quiet points failed, see logs" # Should trigger failure of pre_freeze_script
for i in ${QUIETED}
do
echo " Undo for $i..." >> ${LOGFILE}
proquiet $i disable >/dev/null 2>&1
done
else
echo "All requests succeeded in time." >> ${LOGFILE}
fi
Why to sleep 5 sec before retrying?
1. Copied from the example
2. No idea how long it will take to acquire a quiet point, and 5 sec's seemed reasonable. I'll adjust when and where appropiate.
proquiet exits only when db broker did its part of job and when it talked back to the dbutil:
[2018/01/19@18:16:47.289+0300] P-3224 T-1788 I DBUTIL 5: (5569) Quiet point request login by George on CON:. [2018/01/19@18:16:49.087+0300] P-732 T-9484 I BROKER 0: (5583) Quiet point has been enabled by the broker. [2018/01/19@18:16:49.292+0300] P-3224 T-1788 I DBUTIL 5: (453) Logout by George on CON:. [2018/01/19@20:01:16.418+0300] P-11204 T-1164 I DBUTIL 5: (5569) Quiet point request login by George on CON:. [2018/01/19@20:01:16.641+0300] P-732 T-9484 I BROKER 0: (5584) Quiet point has been disabled by the broker. [2018/01/19@20:01:17.420+0300] P-11204 T-1164 I DBUTIL 5: (453) Logout by George on CON:.
If return code is nonzero then you can run proquiet again immediately.
Anyway the communication between dbutil and broker will /always/ take 1-2 seconds.
george,
why do you
sleep 5 >/dev/null 2>&1
instead of
sleep 5
???
So, now George hijacked my thread? :D
I'm doing sleep 5 >/dev/null 2>&1 to be (absolutely as) sure (as I can) that te script doesn't ouput anything unexpected. I read somewhere that any output from the pre-freeze-script.sh will be interpreted as a failure. Somewhere else I read that an exit 1 means failure and exit 0 means success. I have yet to test that.
>
> So, now George hijacked my thread? :D
>
> I'm doing sleep 5 >/dev/null 2>&1 to be (absolutely as) sure (as I can) that te script doesn't ouput anything unexpected. I read somewhere that any output from the pre-freeze-script.sh will be interpreted as a failure. Somewhere else I read that an exit 1 means failure and exit 0 means success. I have yet to test that.
>
ooops. sorry about that.
yes, exit 0 means success and exit 1 means failure (actually exit nonzero). this has been so since the epoch began. on UNIX and Linux, true for shell scripts as well as executables.
fyi, sleep is a inbuilt command that is part of the shell.
if you are using bash, here is doco:
(bash doc is there even if you arent using bash :))
regards,
gus
“less is my favorite editor. too bad it can’t actually edit files.”
Chris Lesniewski-Laas