Using crontab in Linux for RMAN backup Experiment

Source: Internet
Author: User
To define environment variables, even if the ORACLE user crontab-e is used. Sourcehomeoracle. bash_profile or directly change homeoracle. bash_pr

To define environment variables, even if the ORACLE user crontab-e is used. Source/home/oracle/. bash_profile or directly Mount/home/oracle/. bash_pr

I have previously written a script (see). You can manually execute it. Using crontab, you cannot run it successfully. This afternoon, I spent two hours experimenting with the following:
Note: After the script is complete, run it manually.

When using crontab, pay attention to the following points:
1. Define environment variables, even if the Oracle user crontab-e is used. Source/home/oracle/. bash_profile or directly put the/home/oracle/. bash_profile content at the beginning of the backup script.

2. Pay attention to the absolute path used to call RMAN in the script. Otherwise, crontab cannot be used to run successfully.

For example:/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman

The following is the backup script and setting crontab in LINUX.

I. Backup script format: Only one script is used to back up archived logs, which is faster and easier than full backup. For more scripts, refer to the previous blog.
[Oracle @ oel-01 ~] $ Cat archback. sh
#! /Bin/sh
# Su-oracle
Source/home/oracle/. bash_profile
######## Backarch test 0704
/U01/app/oracle/product/11.2.0/dbhome_1/bin/rman log/home/oracle/rman-arch 'date + % Y % m % d-% H % m'. log < Connect target /;
Run {
Backup archivelog all delete input
Format '/backup/archlog/arch _ % d _ % T _ % s ';
}
Exit


2. Set a crontab scheduled task in LINUX. It was executed at on January 1, July 4.
[Oracle @ oel-01 ~] $ Crontab-e
53 16 4 7 */home/oracle/archback. sh
Save by SHIFT + ZZ as in VI haha. The setting is executed at on January 1, July 4.
[Oracle @ oel-01 ~] $ Crontab-l
53 16 4 7 */home/oracle/archback. sh
[Oracle @ oel-01 ~] $
In this way, you can.

3. logs generated using the archback. sh script:
[Oracle @ oel-01 ~] $ Ls-al rman-arch20130704-1653.log
-Rw-r -- 1 oracle oinstall 1246 Jul 4 rman-arch20130704-1653.log
[Oracle @ oel-01 ~] $ Cat rman-arch20130704-1653.log

Recovery Manager: Release 11.2.0.1.0-Production on Thu Jul 4 16:53:01 2013

Copyright (c) 1982,200 9, Oracle and/or its affiliates. All rights reserved.

RMAN>
Connected to target database: BYS001 (DBID = 2041679290)

RMAN> 2> 3> 4>
Starting backup at 04-JUL-13
Current log archived
Using target database control file instead of recovery catalog
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 41 device type = DISK
Channel ORA_DISK_1: starting archived log backup set
Channel ORA_DISK_1: specifying archived log (s) in backup set
Input archived log thread = 1 sequence = 19 RECID = 111 STAMP = 819910382
Channel ORA_DISK_1: starting piece 1 at 04-JUL-13
Channel ORA_DISK_1: finished piece 1 at 04-JUL-13
Piece handle =/backup/archlog/arch_bys001_30704_119 tag = TAG20130704T165302 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Channel ORA_DISK_1: deleting archived log (s)
Archived log file name =/u01/app/oracle/archbys001/arch_19_415818895125.arc RECID = 111 STAMP = 819910382
Finished backup at 04-JUL-13

Starting Control File and SPFILE Autobackup at 04-JUL-13
Piece handle =/backup/ctl_c-2041679290-20130704-04 comment = NONE
Finished Control File and SPFILE Autobackup at 04-JUL-13

RMAN>

Recovery Manager complete.

Recommended reading:

Basic Oracle tutorial-copying a database through RMAN

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

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.