home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / sybase / 284 < prev    next >
Encoding:
Text File  |  1992-11-10  |  4.1 KB  |  129 lines

  1. Newsgroups: comp.databases.sybase
  2. Path: sparky!uunet!destroyer!cs.ubc.ca!newsserver.sfu.ca!sfu.ca!wolfgang
  3. From: wolfgang@fraser.sfu.ca (Wolfgang Richter)
  4. Subject: Re: Hiding a password while dumping
  5. Message-ID: <wolfgang.721418993@sfu.ca>
  6. Sender: news@sfu.ca
  7. Organization: Simon Fraser University, Burnaby, B.C., Canada
  8. References: <1688@anagld.analytics.com> <93@jcpltyo.JCPL.CO.JP> <94@jcpltyo.JCPL.CO.JP>
  9. Date: Tue, 10 Nov 1992 18:09:53 GMT
  10. Lines: 117
  11.  
  12. The following is a subset of a Unix script that I run twice a day to
  13. do database dumps. Some features:
  14. -  I do not use account sa for doing dumps. Instead I have created
  15.    another account with dump privileges and use it for dumping
  16.    operations.
  17. -  You will have to assign account used for dumping to USERNAME (near
  18.    beginning of the script). Also assign the password to PSWD .
  19.    Of course you will also have to make other changes to reflect your
  20.    installation, such as PATH, directory where you keep transaction
  21.    log files, directory into which you dump files, etc.
  22.    Account password is assigned to variable PSWD in the script.
  23. -  The password will not appear as part of the command -- thus others
  24.    can't snoop via the ps command.
  25. -  No tapes involved. Thus human intervention not required. 
  26. -  When dump is done, files are compressed.
  27. -  We do a nightly tape dump of the volume. A Sybase dump is not to be
  28.    done at the same time. Thus my script checks for the existence of
  29.    a "lock" file that exists only during the duration of the nightly
  30.    tape dump. My script also creates a "lock" file that the nightly
  31.    tape dump looks for (to wait until the Sybase dump is done).
  32. -  The script sends E-mail messages to me if anything goes wrong.
  33.  
  34. ---- Cut here ----- Cut here ------ Cut here ------ Cut here ----------
  35. #!/bin/sh
  36. 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:
  37. LOG_DIR=/usr/local/adm/backup/logs
  38. HOMEDIR=/usr/local/sybase/dump
  39. USERNAME=<fill in>
  40. PSWD=<fill in>
  41. cd $HOMEDIR
  42. TEMPFILE=/tmp/temp$$
  43. touch $TEMPFILE
  44.  
  45. #-- Check that nightly tape backup is not in progress. If it is, then
  46. #-- send message and quit
  47. if [ -f $LOG_DIR/sybase_backup.lock ]
  48.   then
  49.   elm -s "BEAUFORT SYBASE nightly database dump problem" Wolfgang_Richter@sfu.ca <<$
  50. Conflict! Cannot not do database dumps when nightly tape backup is in
  51. progress. Database dump aborted.
  52.  
  53. Note to Wolfgang:
  54.    If this happens too often, will have to reschedule crontab job
  55.    called cronday to run at different times.
  56. $
  57.   exit
  58. fi
  59.  
  60. #-- Create lock file to indicate that this job is now running.
  61. #-- The nightly tape backup system will look for it.
  62. touch lock
  63.  
  64. #
  65. # =======================================
  66. # Dump database MASTER to file master.dmp
  67. # =======================================
  68. touch diskdump1.dat
  69. rm diskdump1.dat
  70. touch diskdump1.dat
  71. rm $TEMPFILE
  72. isql -U${USERNAME} -I/usr/local/sybase/interfaces -SSYBASE <<$ >$TEMPFILE
  73. $PSWD
  74. dump database master to diskdump1
  75. go
  76. $
  77. TEMPLINES=`wc -l<$TEMPFILE`
  78. if [ "$TEMPLINES" != "         1" ]
  79.   then
  80.   rm diskdump1.dat
  81.   tail +2 $TEMPFILE | elm -s "BEAUFORT SYBASE problem with MASTER database" Wolfgang_Richter@sfu.ca
  82.   tail +2 $TEMPFILE
  83. else
  84.   mv diskdump1.dat master.dmp
  85.   chmod go-r master.dmp
  86.   rm master.dmp.Z
  87.   compress master.dmp
  88. fi
  89. #
  90. # =======================================
  91. # Dump database CRC and transaction log
  92. # =======================================
  93. touch diskdump1.dat
  94. rm diskdump1.dat
  95. touch diskdump1.dat
  96. rm $TEMPFILE
  97. isql -U${USERNAME} -I/usr/local/sybase/interfaces -SSYBASE <<$ >$TEMPFILE
  98. $PSWD
  99. dump database crc to diskdump1
  100. go
  101. dump transaction crc to diskdump2
  102. go
  103. $
  104. TEMPLINES=`wc -l<$TEMPFILE`
  105. if [ "$TEMPLINES" != "         1" ]
  106.   then
  107.   rm diskdump1.dat
  108.   tail +2 $TEMPFILE | elm -s "BEAUFORT SYBASE problem with CRC database" Wolfgang_Richter@sfu.ca
  109.   tail +2 $TEMPFILE
  110. else
  111.   touch crc.dmp
  112.   rm crc.dmp
  113.   mv diskdump1.dat crc.dmp
  114.   chmod go-r crc.dmp
  115.   rm crc.dmp.Z
  116.   compress crc.dmp
  117.   touch crclog.dmp
  118.   rm crclog.dmp
  119.   mv diskdump2.dat crclog.dmp
  120.   chmod go-r crclog.dmp
  121.   rm crclog.dmp.Z
  122.   compress crclog.dmp
  123. fi
  124. #
  125. # -- FINAL CLEANUP. Remove the temp file
  126. #
  127. rm $TEMPFILE
  128. rm lock
  129.