Expdp backup using shell script in oracle 11g

Oracle Version: oracle 11g
OS Version:- RHEL 6


[oracle@server1 ~]$ mkdir /backups/db_backup/
[oracle@server1 ~]$ chown -Rf oracle:oinstall /backups/db_backup/
[oracle@server1 ~]$ sqlplus / as sysdba
SQL> CREATE DIRECTORY backup AS '/backups/db_backup/';
SQL> exit

# vi /home/oracle/expdp_backup.sh

#!/bin/bash
export PS1="`/bin/hostname -s`-> "
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=soumyadb
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
path1=/backups/db_backup
date1=`date +%d%m%y_%H%M%S`
/u01/app/oracle/product/11.2.0/db_1/bin/expdp system/system full=y directory=backup dumpfile=backup_$date1.dmp logfile=log_$date1.log exclude=statistics
cd /backups/db_backup/
/bin/tar -zcvf /backups/db_backup/backup_$date1.tar.gz backup_$date1.dmp

:wq



Now schedule the script inside crontab:-
#The expdp script will run everynight at 12 A.M
#crontab -e
0 0 * * * /home/oracle/expdp_backup.sh > /dev/null

Nenhum comentário:

Postar um comentário

Related Posts Plugin for WordPress, Blogger...