Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2007
    Posts
    29

    Post Unanswered: aix : crontab script

    hi..

    i'm newbie here..wanna get some favour.

    server : aix 5.2
    database : sybase

    i wanna make a daily backup script for my database.

    if i use manual backup..the command i wrote is

    $ csh
    $ source SYBASE.csh
    $ isql -Usa -P -SSYBASEKK
    1>dump database mydb to '/dev/rmt1.1'
    2>go


    how to convert into script?

    thanx in advance.

  2. #2
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Hi,

    I'm not familiar with Sybase utilities so I do this from my imagination. What I think you are doing on the command line is: first start a C-shell, then source another scriptfile and after that start a Sybase utility which expects user input twice. If that's the case it possibly can be done in a script like this:
    Code:
    #!/usr/bin/csh
    
    . fullpath/SYBASE.csh
    
    isql -Usa -P -SSYBASEKK<<INPUT
    dump database mydb to '/dev/rmt1.1'
    go
    .
    INPUT
    where I'm not sure about the multiword first inputline. Anyway this is the way to script userinput from the keyboard: redirect the programinput from stdin to a section bound by a label (INPUT). In this section every line with text represents a subsequent line of programinput. After the last line of input an extra line with only a dot marks the end of input and the whole section has to be closed by the same label as that started the section. The label is free of choice and a construction like this is known as a "here-document" in UNIX.

    And if it doesn't work I suggest you put your question in the Sybase forum as well because it's pretty common to script backup operations for databases so also for Sybase.

    Regards

  3. #3
    Join Date
    Jun 2007
    Posts
    29
    hi..

    thanx friend.i try this first.

  4. #4
    Join Date
    Jun 2007
    Posts
    29
    hi..

    i make filename "test" contain

    #!/usr/bin/csh
    . /usr/syb1253/SYBASE.csh
    isql -Usa -P -SSYBASEKK
    dump database mydb to '/usr/syb1253/zihan1.dump'
    go


    when i run this file using sybase ID.this error occurs

    $ test
    /usr/bin/.: The file access permissions do not allow the specified action..
    isql: Command not found.
    dump: Specify at least one of -acdgHhlnoRrsTtz.
    Usage: dump [-X{32|64|32_64|d64|any}] -acdgHhlnopRrsTtuv -t[Index] +tInde
    x -zName[,Number] +zNumber File ...
    go: Command not found.


    what my mistake?

  5. #5
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    First it's better not to call a shell script or executable 'test' because usually there's allready an executable with the name test present in one of your PATH directories (/usr/bin, the shells 'test' command). Giving the command without explicit location will probably do nothing because the executing shell first finds the test executable in /usr/bin and runs that, without any results.

    But from your output I notice that the script is interpreted anyway but the interpreter can't find 'isql' so probably the sourcing is not done the right way. Better replace the '. /usr/syb1253/SYBASE.csh' with 'source /usr/syb1253/SYBASE.csh', if that's functioning on the command line.

    Make sure that you specify the inputparameters for 'isql' in the right way! And that is as described earlier, take my example literally and try it out. All the inputlines, together with the extra last line with the dot have to be surrounded by the label:
    Code:
    $ isql ...<<mylabel
    1>
    2>
    .
    $ mylabel
    Regards

  6. #6
    Join Date
    Jun 2007
    Posts
    29
    thanks friend.

    i rename the namefile from test to dbfile1
    what i found 1st is..it does not recognize 'csh'.is this related to permission?

    i run this file using sybase ID.so to check whether it ok or not..i chmod 777 to dbfile1.but same result too..

    #! /usr/bin/csh -f
    source /usr/syb1253/SYBASE.csh
    isql -Usa -P -SSYBASEKK
    dump database mydb to '/usr/syb1253/mydb.dump'
    go


    $ sh dbfile1
    1[2]: source: not found.
    1[3]: isql: not found.
    dump: Specify at least one of -acdgHhlnoRrsTtz.
    Usage: dump [-X{32|64|32_64|d64|any}] -acdgHhlnopRrsTtuv -t[Index] +tI
    x -zName[,Number] +zNumber File ...
    1[5]: go: not found.

  7. #7
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Quote Originally Posted by rozihan
    #! /usr/bin/csh -f
    There should be no space between ! and /
    else the default Bourne shell is used
    Quote Originally Posted by rozihan
    isql -Usa -P -SSYBASEKK
    You are not using the <<label See post #2 and #5 by Tyveleyn

    Don't write C shell scripts. See

    http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
    http://www.grymoire.com/Unix/CshTop10.txt

    For Bourne type shells Sybase provide environment settings in SYBASE.sh

    ksh script below
    Code:
    #!/usr/bin/ksh
    dbname=$1       # 1st parameter is the database name
    dumpdir=$2      # 2nd parameter is dump directory
    scriptname=${0##*/} # remove path from script name
    if [ "$2" = "" ] 
    then
      echo "Error: missing parameter"
      echo "Syntax: $scriptname <dbname> <backup_dir>"
      exit 8
    fi
    logfile=/tmp/"$scriptname"."$dbname".log$$
    . /usr/syb1253/SYBASE.sh # sybase env (Note dot space slash)
    isql -Usa -P -SSYBASEKK <<EOF >"$logfile"
    dump database $dbname to "compress::$dumpdir/$dbname.dgz"
    go
    EOF
    if [ "$(grep 'DUMP is complete' $logfile )" = "" ]  
    then
      echo dump database "$dbname" failed see "$logfile"
      exit 12
    fi
    I suggest you rename dbfile1 to e.g. sybdump1
    Then to backup mydb to /backup/sybdumps run e.g.
    ./sybdump1 mydb /backup/sybdumps

    And to execute from cron specify the full path to your script e.g.
    30 18 * * * /mydir/scripts/sybdump1 mydb /backup/sybdumps
    Last edited by pdreyer; 06-06-07 at 05:16.

  8. #8
    Join Date
    Jun 2007
    Posts
    29
    thanx friend.

    i'm already done it.it's seem to be ok.and it successfull backup the database.

    1. this backup script make a compress file ( *.dgz). if i wanna restore back the database.can i use this command?

    load database mydb from "/usr/sybase1253/mydb.dgz"


    2. if i wanna backup to tape drive (/dev/rmt1.1), and i have 7 database to backup to the same tape.what to do?


    sori friend..i'm very very newbie to the scripting language.now trying to learn slowly..

  9. #9
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    You need to specify the compress option during load
    load database mydb from "compress::/usr/sybase1253/mydb.dgz"

    I don't use tape backups for my databases.
    I just dump to disk and then the normal O/S backups will backup all files.
    You'll have to use the no rewind tape device to append several dumps to the same tape.
    I don't know what this is on AIX
    On Solaris that is the device with a n added e.g.
    /dev/rmt/0cbn

  10. #10
    Join Date
    Jun 2007
    Posts
    29
    thanx friend..

    yes..i found it on sybase manual..use

    load database mydb from "compress::/usr/sybase1253/mydb.dgz"

    now trying to do script backup into tape.

    thanx again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •