Solved

creating a unix script for dump job in Sybase

Posted on 2008-10-02
3
549 Views
Last Modified: 2013-12-26
Hi ,I am creating a unix job in Sybase to dump the database at certain intervals. I would like ot have 3 copies  of the dump file on the server only at any given time and the job should only email  me if there is any error reported .
The job is as following :
#!/bin/ksh
export SYBASE=/home/sybase/ase1252
export SYBASE_OCS=OCS-12_5
export ISQL=${SYBASE}/${SYBASE_OCS}/bin/isql
export OUTDIR=/backups02/cust2
export USER=sa
export SRVR=sybase2
export PSWD=tables2

${ISQL} -U${USER} -S${SRVR}<<EOF
${PSWD}
dump database cust to '${OUTDIR}/sybase2.cust2.dmp'
go
EOF

Not good in scripting ,appreciate your help .
thanks,Gyans
0
Comment
Question by:gyans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Accepted Solution

by:
Joe Woodhouse earned 400 total points
ID: 22631353
That won't work because you'll overwrite the dump file each time if you use the same name. Most sites put the date & time into the filename to get around that.

I'm doing this away from a ksh so my syntax won't be 100%, but it will be enough to get you going.

Add:

DATE=$( date -u %Y%M%D%h%m)
DB="cust"

FILENAME="${SRVR}.${DB}.${DATE}.dmp"


and later:

dump database ${DB}
to "compress::${OUTDIR}/${FILENAME}"        -- usually faster and always takes less space with compression
go


and then finally something like:

ls -t ${OUTDIR}/${SRVR}.${DB}.* | head +3 | xargs rm

(Not every shell has the same "head" functionality - you want everything *but* the first three files when sorted by time.

This won't work if you stripe your backups, you'll need to be more clever there.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 22631939
> I would like ot have 3 copies
(reusing previous posted code)

DB=cust
SRVR=sybase2
OUTDIR=/backups02/cust2
FILENAME="${OUTDIR}/${SRVR}.${DB}.$(date +%Y%M%D%h%m%S).dmp"

${ISQL} -U${USER} -S${SRVR}<
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL: Comparing 2 Addresses(String) - Identifying Match Percentage 9 399
Hibernate methods 2 88
modThree challenge 4 155
changeXy challenge 13 98
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question