Regular backup of the oracle database of the Linux operating system

Introduction to Linux timing task commands:

Command: crontab

Common parameters:

-l List all scheduled tasks of the current user.

-e Edit current user scheduled task

-d delete the current user's scheduled task

 

[oracle@dblan ~]$ crontab -l
0,15,30,45 * * * * /home/oracle/app/oracle/product/11.2.0/dbhome_1/ccr/bin/emCCR -cron -silent start
0 3 * * 0 /oradata/rmanbak/script/bak_inc0.sh
0 3 * * 3 /oradata/rmanbak/script/bak_inc1.sh
0 3 * * 1,2,4,5,6 /oradata/rmanbak/script/bak_inc2.sh
0 23 * * 6 /home/oracle/dbback/dbback.sh

Scheduled task list content analysis:

*     *     *     *     *      command

hour day month week command you want to execute

 

The first column indicates minutes 1 to 59 every minute with * or */1
the second column indicates hours 1 to 23 (0 indicates 0 o'clock)
the third column indicates the date 1 to 31
the fourth column indicates the month 1 to 12
the fifth column Identification number week 0~6 (0 means Sunday)
Command to be run in column 6

 

example:

0 23 * * 6 /home/oracle/dbback/dbback.sh

 The command to execute the backup every Saturday at 23:00

 

*The column representing time can have multiple values ​​For example:

30 12 1,10,22 * * /home/oracle/dbback/dbback.sh

 Execute the backup task at 12:30 on the 1st, 10th, and 22nd of each month

 

This is the end of the command introduction ********************************************* ***

 

Write export scripts

 

#!/bin/sh
if [ -f ~/.bash_profile ];
then
  . ~/.bash_profile
be

rq=`date '+%Y%m%d%H%M'`
exp "username/password@orcl file=/home/oracle/dbback/$rq.dmp log=/home/oracle/dbback/$rq.log"
zip -m /home/oracle/dbback/$rq.zip /home/oracle/dbback/$rq.dmp /home/oracle/dbback/$rq.log

 After exporting, dmp and log are compressed into one file (the original file is not retained)

 

 

Mark script as executable

 

chmod +x dbback.sh

 

Edit timed tasks (note the current user)

Edit with crontab -e command (if there are other tasks, add a new line)

[oracle@localhost backup]$ crontab -e
30 23 * * * /home/oracle/dbback/dbback.sh

 

 This adds a schedule that runs every day at 23:30

 

 

you're done and good luck

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326717157&siteId=291194637