04-14-2016 08:03 AM
Hello,
Pre/Post script commands for Solaris backup
We need to freeze the “Data Store” on a backup via a pre-script command
How would this work?
the application “Data Store” needs to be placed in a read-only mode prior to any backups being taken, known as a freeze.
To unfreeze (immediately) the Data Store once backup is done -
Would it be possible to do this using the policy settings or we have to insert into a directory?
Any Help, comments or Ideas are appreciated
Solaris client
NBU Client Level 7.6.0.3
Thanks
04-14-2016 08:43 AM
You could write a script on the client that is called via cron, freezes this and once actually frozen call a bpbackup to do a user directed backup.
Otherwise you have bpstart and bpend notify scripts to call the freeze.
https://www.veritas.com/support/en_US/article.TECH162973
Only downside would be that there is no gaurentee of it being frozen by the time the backup hits it which is why I would suggest a script that ensures it before calling bpbackup.
You could defnitely then use the end notify to unfreeze.
04-14-2016 09:21 AM
Thanks mnolan for your response,
I have not written a script before so not sure how to call it. I will take a look at the tech note see if it helps.
04-14-2016 12:54 PM
The "how to use bpstart and bpend notify scripts" tech note is okay. However I need to find more examples of how to call the freeze or a Data store.
Like parameters/statements more along the lines of
To freeze the Data Store file at start of backup:
/usr/pareet/bin/ freeze +<number of seconds>
Example - to freeze for 1 hour:
/usr/pareete/bin/ freeze + 60 minutes
To unfreeze (immediately) the Data Store once backup is done - I guess the name should of the Data Store should be placed in a specific place.
I'm not sure freeze is the correct terminolgy for the script would stop be better?
Thanks
04-20-2016 01:26 PM
Hi, If I wanted to freeze a data base or file where would I put it in the script below?
1 = pheonix
%2 = pheonix1.my company.com
%3 = Pheonix1.schedule
%4 = one of the following: FULL, INCR,
%5 = STATUS, always 0
%6 = RESULT_FILE\netbackup\bin\goodies\bpend_notify.bat
-thanks
04-20-2016 11:01 PM
Any 'notify' scripts need to be moved into the <install path>netbackup\bin (win) or /usr/openv/netbackup/bin (unix) for them to be found and executed.
Note: The return status from the script is checked. Any non-zero status returned from your script will result in a failed job.
04-22-2016 08:55 AM
Hi Mark thanks,
Freeze needs to be done prior to the backup to ensure it does not get corrupted (the filesystem is thousands and thousands of little files that make up the larger files).
content store (TSSTORE)
Apparently bpstart and bpend notify scripts can call a "freeze" not sure exactly how that would be written any suggestion, comments? any examples or other links ?
Thanks
04-22-2016 12:39 PM
If you can set up ssh with key exchange for root on both systems so you don't need a password, You can execute remote commands via ssh.
Something like this in your bpstart script:
ssh root@pheonix '/path_to_exec/freeze -60 minutes'
And in the bpend script:
ssh root@pheonix '/path_to_exec/unfreeze'
Use single quotes.
04-24-2016 03:19 PM
Thanks Dave, That helps
I have never set up ssh with key exhange, I will try,
bpstart script:
ssh root@pheonix '/path_to_exec/freeze -60 minutes'
The "/path_to_exec would be the path on pheonix of the tsstore or the /usr/openv/netbackup/bin?
= pheonix
%2 = pheonix1.my company.com
%3 = Pheonix1.schedule
%4 = one of the following: FULL, INCR,
%5 = STATUS, always 0
%6 = RESULT_FILE\netbackup\bin\goodies\bpend_notify.bat
Thanks
04-25-2016 12:31 AM
Hi nbustarter380,
Can I ask whether you need bpstart_notify and bpend_notify scripts for Solaris, as hinted/indicated by your opening post? Or whether you need the two scripts for Windows, as hinted/indicted by your subsequent posts which refer to DOS/cmd/batch variables (and results file based) ?
04-25-2016 10:56 AM
Hi Sdo,
Sure you can ask I need all the help I can get. I need bpstart_notify and bpend_notify scripts (or something ssh with key exchange? as Dave suggested for a Solaris Client using 7.6.0.3 (sorry for any confusion). Its to freeze a Data Store at the start of a backup.
Similar to the one below that apparently was put in on a similar (solaris client) when we were using a different backup solution.
To freeze the Data Store at start of backup:
/usr/iw-home/bin/ iwfreeze +<number of seconds>
Example - to freeze for 2 hours:
/usr/iw-home/bin/ iwfreeze +7200
To unfreeze (immediately) the Data Store once backup is done - if before the specified freeze time has been reached:
/usr/iw-home/bin/ iwfreeze --
The freeze needs to be prior to backup and unfreeze afterwards.
Again I have actually never done a script before so any help is appreciate.
Thanks again for your replies.
04-25-2016 01:00 PM
If this "data store" application is on the same host/server/client as the backup client software - i.e. if the backup job is backing up what appears to be local file-systems/mount-points (i.e. NOT backing up NFS or SMB network paths) then you should not need to use an "ssh" construct, and instead you should be able to get away with using "su -c command username" in your bpstart_notify and bpend_notify scripts, to call the commands to freeze and unfreeze the "data store" application.
Below is a script that you should be able to modify and drop in the commands that you need.
A word of advice... please take the time to read it carefully and slowly. It's not that difficult to work out what is going on, but you will save yourself a lot headache and time, if you first spend a few minutes absorbing the script.
Take a look in the "log" function, you can uncomment a line there when you test it... BUT... don't forget to comment it out again when you put the code live.
.
N.B: I have tried to make a script which can be used as either or both of bpstart_notify and/or bpend_notify - i.e. so that you only have one piece of code to modify, and thus only one piece of code to drop in as either of, or both of, bpstart_notify or bpend_notify.
N.B: If your NetBackup backup policy uses multi-streaming then this script is not suitable.
N.B: If your client exists in one than one policy then you will very likely need to use the ".POLICYNAME" construct on the file names of the bpstart_notify and bpend_notify scripts.
N.B: Test it first.
N.B: You will see that you will need to modify a few parts - e.g. the cat of redhat-release file, to instead cat the Solaris release file. No doubt there will be a few other parts to tweak for Solaris. Apologies, but I do not have a Solaris system to hand to test this on. Maybe if you get really stuck, someone else on here will step in, take the code below and tweak it up for you for Solaris.
Good luck.
.
Here's the script:
#!/bin/bash ############################################################################################################# # File: bpstart_notify[.POLICYNAME[.SCHEDULENAME]] # bpend_notify[.POLICYNAME[.SCHEDULENAME]] # Purpose: bpstart_notify is called by NetBackup Client at the start of a backup. # bpend_notify is called by NetBackup Client at the end of a backup. # # Vers Date Who Description # ---- ---- --- ----------- # v0.01 14-Apr-2016 sdo Initial draft. # v0.02 16-APR-2016 sdo Fix NBU version file. Handle both start and end. # v0.03 16-APR-2016 sdo List contents of application script. Show whoami. # v0.04 16-APR-2016 sdo bpstart_notify receives 4 parameters, bpend_notify receives 5 parameters. # v0.05 19-APR-2016 sdo Call the application script as user "appadmin". # v0.06 20-APR-2016 sdo Added steps to show application status before and after application call. ############################################################################################################# SCRIPT_VERSION="v0.06" ############################################################################################################# # !!! WARNING and DISCLAIMER !!! # !!! WARNING and DISCLAIMER !!! # !!! WARNING and DISCLAIMER !!! # # Before using this script, be aware of the following points: # - Use of this script is entirely at the end user's own risk. # - Neither the author of this script, nor Veritas, will accept any responsbility for issues or # problems or data loss caused by use, or mis-use, of this script, in either its original form or # a modified form. # - This script is not endorsed by Veritas. # - This script is not supported by Veritas. # - This script has not been tested by Veritas. # - This script may not be suitable for use in any given NetBackup environment. # - This script is furnished on an example basis only. # - Whilst every effort has been made, by the author of this script, to produce something that is # useful and viable, bugs and errors may exist which may cause data loss. ############################################################################################################# # Notes # ----- # 1) Both bpstart_notify and bpend_notify must run silently and not generate any output at all on stdout nor # on stderr. # 2) The Unix/Linux based bpstart_notify scripts do not return their result via "results" file, as the # Windows versions do. Instead "bpstart_notify" returns an "exist status". # 3) The scripts are called by NetBackup Client, and are waited for, up to to a certain client timeout # value. # 4) With default NetBackup Client settings, then if either script takes more than five minutes (i.e. 300 # seconds) to complete, then the backup jobs will be considered as havng failed. # 5) It its current v0.06 form, this script does not handle multi-streaming. ############################################################################################################# function abort { log "Script aborting..." if [ -z "$STS" ] ; then STS=-1; fi if [ $STS -eq 0 ] ; then STS=-1; fi exit $STS } function log { LOGDT=`date "+%d/%m/%Y %H:%M:%S"` # Uncomment this next line during testing..." # echo "$LOGDT $1" echo "$LOGDT $1">>"$FILELOG" # sleep 0.1 } ################################################################################# ################################################################################# SCRIPT_PATH="`dirname $0`" SCRIPT_PATH="`readlink -f ""$SCRIPT_PATH""`" SCRIPT_NAME="`basename $0`" SCRIPT_NAME="${SCRIPT_NAME%%.*}" FILELOG="$SCRIPT_PATH/$SCRIPT_NAME.log" FILETMP="$SCRIPT_PATH/$SCRIPT_NAME.tmp" #don't delete the log file, instead accumulate the log file... #if [ -e "$FILELOG" ] ; then rm "$FILELOG" ; fi if [ -e "$FILETMP" ] ; then rm "$FILETMP" ; fi ((STEP=0)) ################################################################################# ################################################################################# ((STEP++)) log "" log "" log "Step $STEP - show script details..." log "...script name: $SCRIPT_NAME" log "...script path: $SCRIPT_PATH" log "...script log: $FILELOG" log "...script version: $SCRIPT_VERSION" log "...done..." ################################################################################# ################################################################################# ((STEP++)) log "" log "Step $STEP - show server details..." log "...OS kernel: `uname -r`" log ".. OS date: `uname -v`" log "...OS platform: `uname -m -p -i -o`" log "...OS release: `cat /etc/redhat-release`" log "...hostname: $HOSTNAME" log "...process ID: $$" log "...num params: $#" log "...username: `whoami`" log "...current path: `pwd`" log "...done..." ################################################################################# ################################################################################# ((STEP++)) log "" log "Step $STEP - show NetBackup details..." log "...NetBackup version: `cat /usr/openv/netbackup/bin/version`" log ".. client name: $1" log "...policy name: $2" log "...schedule name: $3" log "...schedule type: $4" log "...parameter 5: $5" log "...BACKUPID: $BACKUPID" log "...BACKUPTIME: $BACKUPTIME" log "...STREAM_NUMBER: $STREAM_NUMBER" log "...STREAM_COUNT: $STREAM_COUNT" log "...STREAM_PID: $STREAM_PID" if [ "`echo $SCRIPT_NAME | cut -d "_" -f 1`" = "bpstart" ] then SCRIPT_MODE="bpstart" else if [ "`echo $SCRIPT_NAME | cut -d "_" -f 1`" = "bpend" ] then SCRIPT_MODE="bpend" else log "...unable to determine script mode from file name of NetBackup script name, script aboting..." abort fi fi if [ "$SCRIPT_MODE" = "bpstart" ] then if [ "$#" -ne 4 ] then log "...incorrect number of parameters '$#', expected '4', script aborting..." abort fi else if [ "$#" - ne 5 ] then log "...incorrect number of parameters '$#', expected '5', script aborting..." abort fi fi if [ "$SCRIPT_MODE" = "bpstart" ] then log "...RESTARTED: $RESTARTED" else log "...FINISHED: $FINISHED" fi log "...done..." ################################################################################# ################################################################################# ((STEP++)) log "" log "Step $STEP - show current application status, before taking action..." #command-to-display-application-status >>"$FILELOG" 2>&1 STSDSP=$? log "...return status from application show was '$STSDSP', script continuing..." log "...done..." ################################################################################# ################################################################################# ((STEP++)) log "" log "Step $STEP - locate and call script to start/stop application..." if [ "$SCRIPT_MODE" = "bpstart" ] then APP_SCRIPT="/home/application/scripts/stop_APP.sh" else APP_SCRIPT="/home/application/scripts/start_APP.sh" fi log "...the application script file to call is named: $APP_SCRIPT" if [ ! -e "$APP_SCRIPT" ] then log "...unable to locate application script file, script aborting..." abort fi log "...listing application script file..." ls -lash $APP_SCRIPT >>"$FILELOG" 2>&1 log "...showing application script file contents..." cat $APP_SCRIPT >>"$FILELOG" 2>&1 log "...calling application script..." su -c $APP_SCRIPT appadmin >>"$FILELOG" 2>&1 STS=$? if [ $STS -ne 0 ] then if [ "$SCRIPT_MODE" = "bpstart" ] then # comment and uncomment the next one/two/three lines to change the behaviour of this script... log "...call to application script failed, status '$STS', script continuing..." # log "...call to application script failed, status '$STS', script aborting..." # abort else log "...call to application script failed, status '$STS', script aborting..." abort fi fi log "...done..." ################################################################################# ################################################################################# ((STEP++)) log "" log "Step $STEP - show current application status, after taking action..." #command-to-show-application-status >>"$FILELOG" 2>&1 STSDSP=$? log "...return status from application show was '$STSDSP', script continuing..." log "...done..." ################################################################################# ################################################################################# log "" log "Script exiting..." exit 0
04-26-2016 05:14 AM
Hi Sdo,
Thank you very for that script I really appreciate you taking time to post it. I will read it over carefully as it is something I could not have come up with.
Best Regards