Centos6.4-rman Scheduled task backup on 11GR2

Source: Internet
Author: User
Tags cron script

1. Rman Backup Script Location:

/home/oracle

./scripts/

./bin-----Storing Rman scripts

./log-----Store timed task execution logs

2./bin Script Planning:

Script Planning
rmancfg.sh Rman parameter Configuration script Execute once
inc0.sh Rman Level 0 Backup Backup path Parameters
inc1.sh Rman level Backup Backup path Parameters
inc0cron.sh Level 0 Backup Timing Script Oracle Environment variables
inc1cron.sh First-level backup timing script Oracle Environment variables
del.sh Delete outdated backup data
delcron.sh Expired Backup Check Delete timed script Oracle Environment variables

3. Rman Script Content

Add the environment variables used to the. Bash_profile of the Oracle user,

In the back cron script, source ~/.bash_profile can.

VI./bin/profile.env

Export Nls_lang=american_america. Zhs16gbk
Export nls_date_format= ' Yyyy-mm-dd hh24:mi:ss '
Export Rman_bakpath=/rman/bak
Export dt= ' date + '%y%m%d%h%m '
Export days=15
Export Catlu=rmanbak
Export Catlp=rmanbak

======================================================================================================

./inc0.sh (using the Catalog library to store backup information)

Rman target/catalog $catlu/$CATLP << EOF
run{
Backup as compressed Backupset incremental level 0 database format ' $rman _bakpath/%d_level0_%s_%y%m%d.bak ';
SQL ' alter system archive log current ';
Backup as compressed backupset archivelog all format ' $rman _bakpath/%d_arch_%s_%y%m%d_%u.bak ' Delete all input;
Backup as compressed backupset current controlfile format ' $rman _bakpath/%d_control_%s_%y%m%d_%u.bak ';
}
Eof

======================================================================================================

./inc1.sh (using the Catalog library to store backup information)

Rman target/catalog $catlu/$CATLP << EOF
run{
Backup as compressed Backupset incremental Level 1 database format ' $rman _bakpath/%d_level1_%s_%y%m%d.bak ';
SQL ' alter system archive log current ';
Backup as compressed backupset archivelog all format ' $rman _bakpath/%d_arch_%s_%y%m%d_%u.bak ' Delete all input;
Backup as compressed backupset current controlfile format ' $rman _bakpath/%d_control_%s_%y%m%d_%u.bak ';
}
Eof

======================================================================================================

./del.sh

Rman target/catalog $catlu/$CATLP << EOF
run{
Crosscheck Archivelog All;
Crosscheck backup;
Delete noprompt expired backup;
Delete noprompt expired archivelog all;
Delete NoPrompt obsolete;
Delete noprompt Archivelog until time ' sysdate-$days ';
Delete noprompt backup until time ' sysdate-$days ';
}
Eof

=====================================================================================================

4. crontab timed Task script content

./inc0cron.sh

SOURCE ~/.bash_profile
cd/home/oracle/scripts/bin/&&/inc0.sh >. /log/inc0_$dt.log

--------------------------------------------------------------------------------------------------------------- -------------------------

./inc1cron.sh

SOURCE ~/.bash_profile
cd/home/oracle/scripts/bin/&&/inc1.sh >. /log/inc1_$dt.log

--------------------------------------------------------------------------------------------------------------- -------------------------

./delcron.sh

SOURCE ~/.bash_profile
cd/home/oracle/scripts/bin/&&/del.sh >. /log/del_$dt.log

--------------------------------------------------------------------------------------------------------------- -------------------------

./rmancfg.sh This script can be executed manually once. No source ~/.bash_profile Required

Cat ~/scripts/bin/profile.env >> ~/.bash_profile

cores= (' lscpu | grep ' ^cpu (s) ' |awk {' Print $ '} ')

If [$cores-gt 16]; Then
Cores=16
Fi
Rman Target/<< EOF
run{
CONFIGURE DEVICE type DISK PARALLELISM $cores BACKUP type to BACKUPSET;
CONFIGURE RETENTION POLICY to RECOVERY windows of $days days;
CONFIGURE BACKUP optimization on;
}
Eof

--------------------------------------------------------------------------------------------------------------- -------------------------

5. Su-oracle Add timed Tasks

$crontab-E

*/14 * */home/oracle/scripts/bin/inc0cron.sh
* * 5/home/oracle/scripts/bin/inc1cron.sh
0 0 */15 * */home/oracle/scripts/bin/delcron.sh

--------------------------------------------------------------------------------------------------------------- -------------------------

Scheduled Tasks for Oracle users:

The Cron Timer task program simply executes the script with the Oracle user and does not log on to the Oracle user.
Therefore, you need to source a good Oracle user environment variable in the script. Otherwise, the scheduled task cannot be executed.

The./*.sh is the fork method, source *.sh and. *sh (dot plus space plus script file) is the method of source.
Execution of a child command resumes execution of the parent command, while the environment variables set by the child affect the environment variables of the parent.
The difference between source and fork is that it does not open a new Sub-shell to execute the called script, but rather executes it in the same shell.
So the variables and environment variables declared in the invoked script can be obtained and used in the main script.

During the debug execution of a scheduled task, you can use tail-f/var/spool/mail/oracle to monitor the execution of a scheduled task error message.

Note: ~/scripts/bin/profile.env needs to be configured according to the actual environment.

Ext.: http://m.blog.csdn.net/article/details?id=52537568

Centos6.4-rman Scheduled task backup on 11GR2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.