Solved

creating a unix script for dump job in Sybase

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 49
Unix / Linux grid computing 5 157
isEverywhere  challenge 19 78
How to convert MFC::CString to UTF8 wchar_t* 10 214
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 …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

823 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