Solved

creating a unix script for dump job in Sybase

Posted on 2008-10-02
3
513 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 37
I need expert Sybase Sql help with a query 3 61
canBalance challenge 34 70
changeXy challenge 13 67
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now