A. Rodney Rutherford wrote
(16 May 2000):
(Solaris server/client example
with the groupname TEST)
Client has savepnpc specified
in the "Backup command:" field on server
/nsr/res/TEST.res file on
client contains:
type: savepnpc;
precmd: /nsr/bin/precmd.sh;
pstcmd: /nsr/bin/pstcmd.sh;
timeout: "11:00pm";
When a savegroup starts the
following happens (example using the group TEST):
-
The server starts the group.
-
The server sees the client has
savepnpc specified as the backup command.
-
The server contacts the client
and checks for a /nsr/res/TEST.res file. (If there is not one, a dummy
res file will be created.)
-
The client executes the pre
command/script specified in the file (precmd: /nsr/bin/precmd.sh;). It
creates a tmp file indicating that savepnpc is running, /nsr/tmp/TEST.tmp
-
It also executes a process that
monitors the status of the saves waiting for completion and/or the timeout
value specified in /nsr/res/TEST.res. (timeout: "11:00pm";)
-
After the pre script successfully
completes, the server then initiates the filesystem saves.
-
During this time the client
is constantly checking the server to see if the saves are completed. As
soon as they have completed (or the timeout value has been reached), the client executes the post script specified in the /nsr/res/TEST.res file.
(pstcmd: /nsr/bin/pstcmd.sh) It then removes the /nsr/tmp/TEST.tmp file.
NOTES:
-
The pre/post scripts need to
have the necessary environment setup in them, as savepnpc does not pass
any kind of environment to the scripts.
-
The start/stop of the pre and
post commands are recorded in /nsr/logs/savepnpc.log
-
If the pre command fails (exit
status non-zero), the saves for that client will abort and not be run.
It will also not start the post command process, so the post script will
never run and the /nsr/tmp/TEST.tmp file will be left. You will need to
remove this by hand.
-
If a savegroup session is manually
aborted or stopped on the server, the /nsr/tmp/TEST.tmp file is left. (This
is because the server allows you to restart it later.) Also, because an
abort does not clear up the work list for the client,the client still thinks
there are saves to be completed and the post script will not run.
-
If a new savegroup session is
started and there is an existing /nsr/tmp/TEST.tmp file, it will skip the
pre/post commands; however it will run the filesystem save sessions.
About a month later,
Rodney Wines & W. Curtis Preston discussed savepnpc (15 June 2000).
Their discussion is what resulted in the summary below. There are contributions
from both Rodney and Curtis.
Most of the documentation on how to use savepnpc is lacking. What follows is a summary of the 'gotchas'
for this little feature. The information below applies to both NT and UNIX
clients.
-
Specify savepncp as the backup
command in the client config.
-
Put the /nsr/res/<groupname>.res
file on the client, not the server. If you're not sure where it goes, run
a group backup and it will create an example file for you. Check /nsr/res
or <nsrroot>\nsr\res.
-
There is a limited path environment
with savepnpc. Therefore, you must use full path names for any commands.
-
You must escape any '\' characters
in the <groupname>.res file by using an extra '\' before them. (e.g.
c:\dir\command.exe -> c:\\dir\\command.exe) You DON'T need to dothis in
the shell script or batch file that you may be running, just in the <groupname>.res
file.
-
Savepnpc also doesn't pass arguments
well to commands. (Some have apparently done it, but it doesn't always
work.)
-
The best way around the path
and arguments problems is to put all your commands in a script and put
that script's full pathname on the precmd or postcmd line. In this script,
you can define any environment variables you need (including PATH) on NT,
and source any login scripts on Unix that you want to.
-
Do not use savepnpc with groups
that have a space in their name.
-
If savepnpc has been running
successfully for a while, then the backup starts behaving like a normal
backup, look for an /nsr/tmp/<groupname>.tmp. This is a lock file that
is created the first time a savepnpc is run during a backup session, and
is normally removed when all savesets for a system have completed. However,
if a backup for a client is aborted or the client crashes, the ".../<groupname>.tmp"
file can be left around. The next time savepnpc runs, it will assume that
the preprocessing commands have already run and will skip them, and the
postprocessing commands will be skipped as well.
-
On NT, don't use '@ECHO OFF'
in the <groupname>.res file.
-
The scripts/batch files that
you do create do NOT have to be in /nsr/bin, but you do have to put their
full path in the <groupname>.res file.
-
Anything written to standard
output by the preprocessing commands will appear in the savegroup completion
notice. If this output is verbose, it'll be a nuisance. You might prefer
to direct the output from the commands in your script to a log file for
later examination.
-
You won't see the output from
the postprocessing commands, because the connection to the server has already
dropped when these commands are run. I'd recommend redirecting their output
to a log file so you can examine the result if something failed to restart.
I have seen postprocessing commands fail when they didn't have someplace
to write their standard output, so I recommend always redirecting them
to a log.
-
The preprocessing commands MUST
return "success" (at least on Unix). If they return a failure code, each
saveset backup will be skipped, and you'll get a message like "...! no
output" in the completion notice for each saveset on the client.
The problem with the <GROUP>.tmp mentioned in this section is potentially quite serious. The symptom is that pre and post processing will fail silently, and the chances are that this will cause useless backups, e.g. of databases that are running and cannot be recovered. The savefixpnpc script solves this. This script was written in 1998 and has recently been updated to work with 6.1.1 and 6.1.2 on Solaris and HP-UX.
Here is the latest savefixpnpc:
#!/bin/ksh
# savefixpnpc V6.1.1, workaround for Legato bug LGTpa06002.
# Author Dave Driver, Legato Systems, 1999.
# This script is used on the client as the backup command.
# Place this script in the same directory as the save command.
# Configure the "backup command" field in the client to be savefixpnpc.
# This script is totally unsupported, and is used at the user's own risk.
# Legato Support provides no support for this script.
# Originally written for NW 5.5.x on Solaris.
# Updated November 2002 by Dave Driver, http://www.DriveConsultants.com/
# to allow new command line options for the save command, and for HP-UX.
# Now validated for all NetWorker versions up to 6.1.1.
# Not tested on other Unix platforms or NetWorker versions higher than 6.1.1.
export PATH=/bin:/usr/bin:/usr/sbin:/opt/networker/bin
SAVEPARMS=
while getopts s:c:N:e:f:b:F:I:g:l:t:m:w:y:W:BEiLnquSVvx OPT
do
case $OPT in
g) SAVEPARMS="$SAVEPARMS -$OPT $OPTARG"; GROUP=$OPTARG ;;
*) SAVEPARMS="$SAVEPARMS -$OPT $OPTARG" ;;
esac
done
shift $(($OPTIND - 1))
SS=$@
SPNPCTMP=/nsr/tmp/$GROUP.tmp
# Find out if group is already running
ps -ef | egrep "preclntsave|pstclntsave" | grep "\-g $GROUP" \
| tail -1 | read undef PCLNTSAVEPID undef
# If the process is not present we want to be sure that the tmp
# file does not exist. This could happen if a previous group
# had terminated abnormally.
if [ -z "$PCLNTSAVEPID" ] && [ -f $SPNPCTMP ]; then
# tmp file exists, and we think it is redundant, but double check
sleep $(($RANDOM/3276+10))
ps -ef | egrep "preclntsave|pstclntsave" | grep "\-g $GROUP" \
| tail -1 | read undef PCLNTSAVEPID undef
if [ -z "$PCLNTSAVEPID" ] && [ -f $SPNPCTMP ]; then
rm -f $SPNPCTMP
# Now wait a while so we don't recreate it too soon
sleep 3
fi
fi
exec savepnpc $SAVEPARMS $SS 2>&1