Difference between revisions of "Auto Backup of Oracle Database"
Jump to navigation
Jump to search
(Created page with " Create a backup script file; <pre> vim /home/oracle/oraclebackup.sh </pre> Write following code in oraclebackup.sh file <pre> export ORACLE_BASE=/u01/app/oracle export ORA...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 29: | Line 29: | ||
</pre> | </pre> | ||
− | Understanding Cron | + | Understanding Cron Job scheduler; |
<pre> | <pre> | ||
Line 35: | Line 35: | ||
Minute | Hour | Day | Month | DayOfWeek | user | ThingToDo | Minute | Hour | Day | Month | DayOfWeek | user | ThingToDo | ||
− | 'user' is the account name for the 'ThingToDo' to be run under. | + | 'user' is the account name for the 'ThingToDo' to be run under. We are not using 'user', it will run by default user. |
'ThingToDo' is as per any command line syntax. Typically, it invokes a script. | 'ThingToDo' is as per any command line syntax. Typically, it invokes a script. | ||
'Day' and 'Date' are easy to understand, but very difficult to read in their raw form | 'Day' and 'Date' are easy to understand, but very difficult to read in their raw form |
Latest revision as of 13:06, 22 December 2016
Create a backup script file;
vim /home/oracle/oraclebackup.sh
Write following code in oraclebackup.sh file
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 export PATH=$ORACLE_HOME/bin:$PATH export ORACLE_SID=SMARTHCM expdp system/password@pdbsmarthcm schemas=smarthcm directory=data_dump dumpfile=smarthcm mv /u01/data_dump/smarthcm.dmp /u01/data_dump/smarthcm_`date +%Y_%m_%d_%H`.dmp
Create a Cron Job;
crontab -e
Insert following schedule in cron job;
0 23 * * * /home/oracle/oraclebackup.sh
Understanding Cron Job scheduler;
Crontab Format: Minute | Hour | Day | Month | DayOfWeek | user | ThingToDo 'user' is the account name for the 'ThingToDo' to be run under. We are not using 'user', it will run by default user. 'ThingToDo' is as per any command line syntax. Typically, it invokes a script. 'Day' and 'Date' are easy to understand, but very difficult to read in their raw form
Thus, our cron job will execute the script oraclebackup.sh on 23:00 hours daily.