Solved

creating a unix script for dump job in Sybase

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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