Create oracle Dump Backup with cron schedule in linux 6
prerequisites and assumption :
- Oracle 11gr2 installed on linux 6.5
- installed DB name : orcl
- HR schema
- knowledge of using VI editor ( i : to insert , ESC ans :wq to save the content )
Follow below Steps :
- Create shell file named "auto_dump.sh" in /u01/DUMPBACKUP :
- vi /u01/DUMPBACKUP/auto_dump.sh
- paste the following
# please update hostname,oracle_base,oracle_unqname and SID to suite your installation
ORACLE_HOSTNAME=linux6.site; export ORACLE_HOSTNAME ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME ORACLE_SID=orcl; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
# dump and log file names with date formatDUMPFILE=$(date '+expdp_%Y_%m_%d_%s.dmp')LOGFILE=$(date '+expdp_%Y_%m_%d_%s.log')
# please update user to your powerful user
USER=system
PWD=your_password
# please specify your schema or FULL=y
expdp $USER/$PWD compression=all SCHEMAS=HR DIRECTORY=datapump_exp_imp_file dumpfile=$DUMPFILE logfile=$LOGFILE
exit
- ESC and :wq to save content
- as root user :
- mkdir -p /u01/DUMPBACKUP
- chown -R oracle:oinstall /u01/DUMPBACKUP
- chmod -R 775 /u01/DUMPBACKUP
- Login to SQL as sysdba
- sql>create or replace directory datapump_exp_imp_file as '/u01/DUMPBACKUP';
- test shell manually in terminal :
- bash /u01/DUMPBACKUP/auto_dump.sh
- to schedule shell:
- crontab -e
- to run at 6 am every day add the following line
- 0 6 * * * /u01/DUMPBACKUP/auto_dump.sh >> /u01/DUMPBACKUP/Dump_export.log 2>&1
- :wq
No comments:
Post a Comment