From: wolfgang@fraser.sfu.ca (Wolfgang Richter)
Subject: Re: Hiding a password while dumping
Organization: Simon Fraser University, Burnaby, B.C., Canada
Date: Tue, 10 Nov 1992 18:09:53 GMT

The following is a subset of a Unix script that I run twice a day to
do database dumps. Some features:
-  I do not use account sa for doing dumps. Instead I have created
   another account with dump privileges and use it for dumping
   operations.
-  You will have to assign account used for dumping to USERNAME (near
   beginning of the script). Also assign the password to PSWD .
   Of course you will also have to make other changes to reflect your
   installation, such as PATH, directory where you keep transaction
   log files, directory into which you dump files, etc.
   Account password is assigned to variable PSWD in the script.
-  The password will not appear as part of the command -- thus others
   can't snoop via the ps command.
-  No tapes involved. Thus human intervention not required. 
-  When dump is done, files are compressed.
-  We do a nightly tape dump of the volume. A Sybase dump is not to be
   done at the same time. Thus my script checks for the existence of
   a "lock" file that exists only during the duration of the nightly
   tape dump. My script also creates a "lock" file that the nightly
   tape dump looks for (to wait until the Sybase dump is done).
-  The script sends E-mail messages to me if anything goes wrong.

---- Cut here ----- Cut here ------ Cut here ------ Cut here ----------
#!/bin/sh
PATH=/usr/local/sybase/bin:/usr/local/bin:/usr/5bin:/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/sbin:/usr/local/sybase/bin:/usr/old:/usr/local/etc:/usr/etc:
LOG_DIR=/usr/local/adm/backup/logs
HOMEDIR=/usr/local/sybase/dump
USERNAME=<fill in>
PSWD=<fill in>
cd $HOMEDIR
TEMPFILE=/tmp/temp$$
touch $TEMPFILE

#-- Check that nightly tape backup is not in progress. If it is, then
#-- send message and quit
if [ -f $LOG_DIR/sybase_backup.lock ]
  then
  elm -s "BEAUFORT SYBASE nightly database dump problem" Wolfgang_Richter@sfu.ca <<$
Conflict! Cannot not do database dumps when nightly tape backup is in
progress. Database dump aborted.

Note to Wolfgang:
   If this happens too often, will have to reschedule crontab job
   called cronday to run at different times.
$
  exit
fi

#-- Create lock file to indicate that this job is now running.
#-- The nightly tape backup system will look for it.
touch lock

#
# =======================================
# Dump database MASTER to file master.dmp
# =======================================
touch diskdump1.dat
rm diskdump1.dat
touch diskdump1.dat
rm $TEMPFILE
isql -U${USERNAME} -I/usr/local/sybase/interfaces -SSYBASE <<$ >$TEMPFILE
$PSWD
dump database master to diskdump1
go
$
TEMPLINES=`wc -l<$TEMPFILE`
if [ "$TEMPLINES" != "         1" ]
  then
  rm diskdump1.dat
  tail +2 $TEMPFILE | elm -s "BEAUFORT SYBASE problem with MASTER database" Wolfgang_Richter@sfu.ca
  tail +2 $TEMPFILE
else
  mv diskdump1.dat master.dmp
  chmod go-r master.dmp
  rm master.dmp.Z
  compress master.dmp
fi
#
# =======================================
# Dump database CRC and transaction log
# =======================================
touch diskdump1.dat
rm diskdump1.dat
touch diskdump1.dat
rm $TEMPFILE
isql -U${USERNAME} -I/usr/local/sybase/interfaces -SSYBASE <<$ >$TEMPFILE
$PSWD
dump database crc to diskdump1
go
dump transaction crc to diskdump2
go
$
TEMPLINES=`wc -l<$TEMPFILE`
if [ "$TEMPLINES" != "         1" ]
  then
  rm diskdump1.dat
  tail +2 $TEMPFILE | elm -s "BEAUFORT SYBASE problem with CRC database" Wolfgang_Richter@sfu.ca
  tail +2 $TEMPFILE
else
  touch crc.dmp
  rm crc.dmp
  mv diskdump1.dat crc.dmp
  chmod go-r crc.dmp
  rm crc.dmp.Z
  compress crc.dmp
  touch crclog.dmp
  rm crclog.dmp
  mv diskdump2.dat crclog.dmp
  chmod go-r crclog.dmp
  rm crclog.dmp.Z
  compress crclog.dmp
fi
#
# -- FINAL CLEANUP. Remove the temp file
#
rm $TEMPFILE
rm lock
Newsgroups: comp.databases.sybase