Create Oracle Schedule Backup Script on Oracle Linux :


  1. create backup directory for USERME

    CREATE OR REPLACE DIRECTORY BCK_DIR AS ‘/home/oracle/bck’;
    GRANT READ, WRITE ON DIRECTORY SYS.BCK_DIR TO EXP_FULL_DATABASE;
    GRANT READ, WRITE ON DIRECTORY SYS.BCK_DIR TO IMP_FULL_DATABASE;

  2. using vi to create script

    #!/bin/bash
    clear
    #echo “Hello, linux world from pandazen world.”
    echo “backup pandazen data with script on Oracle Linux”
    NOW=$(date +”%Y%m%d”)
    FILE=”pandazen$NOW”
    echo $FILE

    #export data pump with compression
    expdp USERME/<PASSWORD> dumpfile=$FILE.dmp logfile=$FILE.log directory=BCK_DIR compression=all

    #archive with tar
    tar -cf $FILE.tar $FILE.dmp $FILE.log

    #compress again with gzip
    gzip $FILE.tar
    [ESC]
    :wq

  3. using crontab to schedule it

    crontab -e
    0 22 * * * /home/oracle/script/bckmis.sh
    [ESC]
    :wq

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: