Saturday, 3 December 2011

Schedule Full Export Backup

If you want to automate the export backup daily at any schedule time say 1AM, zip it and remove the old backup dump files then check these steps

Create Directory:
SQL> CREATE OR REPLACE DIRECTORY DATAPUMP_ORCL AS '/orabackup/EXPDP/';
SQL> GRANT READ, WRITE ON DIRECTORY DATAPUMP_ORCL to system;

Cron entry:
00 01 * * * sh /orabackup/EXPDP/dailydp.sh > /orabackup/EXPDP/dailydp.log

Backup Script:
vi /orabackup/EXPDP/dailydp.sh
export ORACLE_HOME=/orahome/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
$ORACLE_HOME/bin/expdp system/pwd directory=DATAPUMP_ORCL dumpfile="fulldp_orcl"`date '+%d%m%y'` logfile=fulldp_orcl.log full=y
gzip "/orabackup/EXPDP/fulldp_orcl"`date '+%d%m%y'.dmp`
find /orabackup/EXPDP -name  "*.dmp.gz" -mtime +7 -exec rm {} \;

No comments:

Post a Comment