Skip to main content

rman backup script in crontab

rman backup script fails to run in crontab where as it will succeed if executed manually.

Here i am going to use a simple script just to demonstrate the successful run of rman backup script in crontab.

If cronjob failed then it will generate the log information in "/var/mail/ora11g" (here ora11g is username)

If the script is not written properly then it will give error messages as below:



/home/ora11g/db_scripts/rman_bkp1.sh[6]: RUN: not found [No such file or directory]
/home/ora11g/db_scripts/rman_bkp1.sh[7]: ALLOCATE: not found [No such file or directory]
/home/ora11g/db_scripts/rman_bkp1.sh[8]: DISK: not found [No such file or directory]
/home/ora11g/db_scripts/rman_bkp1.sh[9]: BACKUP: not found [No such file or directory]
/home/ora11g/db_scripts/rman_bkp1.sh[10]: RELEASE: not found [No such file or directory]
/home/ora11g/db_scripts/rman_bkp1.sh: line 10: syntax error at line 11: `}' unexpected



sample script which will run successful in crontab:





There is no backup for this database in repository:



[ora11g@oelrac1 db_scripts]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Mar 27 13:25:21 2012

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

RMAN> connect target

connected to target database: TESTRAC (DBID=155295882)

RMAN> list backup;

using target database control file instead of recovery catalog
specification does not match any backup in the repository

RMAN>




I have schedule cronjob to execute at 13:28 hours. This will generate logfile "/home/ora11g/db_scripts/logs/cron1" for this session:



[ora11g@oelrac1 db_scripts]$ crontab -l
28 13 * * * /home/ora11g/db_scripts/rman_bkp1.sh ORA11G > /home/ora11g/db_scripts/logs/cron1
[ora11g@oelrac1 db_scripts]$ date
Tue Mar 27 13:26:49 AST 2012
[ora11g@oelrac1 db_scripts]$






[ora11g@oelrac1 logs]$ ls -lrt
total 8
drwxr-xr-x 2 ora11g dba 4096 Mar 27 12:03 cron
-rw-r--r-- 1 ora11g dba 1778 Mar 27 13:29 cron1
[ora11g@oelrac1 logs]$ pwd
/home/ora11g/db_scripts/logs
[ora11g@oelrac1 logs]$




content of rman backup cronjob logfile:



[ora11g@oelrac1 logs]$ more cron1

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Mar 27 13:28:02 2012

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

connected to target database: TESTRAC (DBID=155295882)

RMAN> 2> 3> 4> 5> 6>
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=33 instance=testrac1 device type=DISK

Starting backup at 27-MAR-12
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00001 name=+RACDATA/testrac/datafile/system.256.777637199
input datafile file number=00002 name=+RACDATA/testrac/datafile/sysaux.257.777637203
input datafile file number=00003 name=+RACDATA/testrac/datafile/undotbs1.258.777637203
input datafile file number=00005 name=+RACDATA/testrac/datafile/example.264.777637363
input datafile file number=00006 name=+RACDATA/testrac/datafile/undotbs2.265.777637637
input datafile file number=00004 name=+RACDATA/testrac/datafile/users.259.777637203
channel ch1: starting piece 1 at 27-MAR-12
channel ch1: finished piece 1 at 27-MAR-12
piece handle=/u01/11g_db/rman_db_backups/TESTRAC_DB_0dn6u4b6_13_1 tag=TAG20120327T132806 comment=NONE
channel ch1: backup set complete, elapsed time: 00:01:08
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ch1: starting piece 1 at 27-MAR-12
channel ch1: finished piece 1 at 27-MAR-12
piece handle=/u01/11g_db/rman_db_backups/TESTRAC_DB_0en6u4dc_14_1 tag=TAG20120327T132806 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:03
Finished backup at 27-MAR-12

released channel: ch1

RMAN>

Recovery Manager complete.




After successful backup information in repository:




[ora11g@oelrac1 db_scripts]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Mar 27 13:30:43 2012

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

RMAN> connect target

connected to target database: TESTRAC (DBID=155295882)

RMAN> list backup;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
13 Full 1.06G DISK 00:01:07 27-MAR-12
BP Key: 13 Status: AVAILABLE Compressed: NO Tag: TAG20120327T132806
Piece Name: /u01/11g_db/rman_db_backups/TESTRAC_DB_0dn6u4b6_13_1
List of Datafiles in backup set 13
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1061149 27-MAR-12 +RACDATA/testrac/datafile/system.256.777637199
2 Full 1061149 27-MAR-12 +RACDATA/testrac/datafile/sysaux.257.777637203
3 Full 1061149 27-MAR-12 +RACDATA/testrac/datafile/undotbs1.258.777637203
4 Full 1061149 27-MAR-12 +RACDATA/testrac/datafile/users.259.777637203
5 Full 1061149 27-MAR-12 +RACDATA/testrac/datafile/example.264.777637363
6 Full 1061149 27-MAR-12 +RACDATA/testrac/datafile/undotbs2.265.777637637

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
14 Full 17.70M DISK 00:00:08 27-MAR-12
BP Key: 14 Status: AVAILABLE Compressed: NO Tag: TAG20120327T132806
Piece Name: /u01/11g_db/rman_db_backups/TESTRAC_DB_0en6u4dc_14_1
SPFILE Included: Modification time: 27-MAR-12
SPFILE db_unique_name: TESTRAC
Control File Included: Ckp SCN: 1061326 Ckp time: 27-MAR-12

RMAN>




Hope this helps :)

thanks for reading.

regards,
Syed Zaheer

Comments

Anonymous said…
know about scheduling jobs with crontab command examples

Popular posts from this blog

Disable Firewall on Oracle Linux 8

In this blogpost we will see how we can stop/disable the firewall on Oracle Linux 8, the firewall command is same in both linux 7 an linux 8. The below listed is the procedure for stopping and disabling the  firewall on Oracle Linux 8. - Here we can see the firewall deamon in active state - Here when we stop the firewall in previous command, now the firewall daemon is dead - For permanent disabling the firewall on server, we can use "disable" option The following commands will be helpful: #systemctl status firewalld #systemctl stop firewalld #systemctl disable firewalld #systemctl enable firewalld #systemctl start firewalld Hope it helps !! Thanks for reading :) regards, X A H E E R

Enable Desktop on Oracle Solaris 11.4

Oracle Solaris 11 installation has multiple options to choose for installation of an Operating Environment, but mostly Oracle Solaris text install media is used and this installation media doesn't offer the GUI Desktop Environment by default after the installation. This blog post will explain how we can enable the desktop for Oracle Solaris 11.4 operating system, after the completion of installation. We have to install "solaris-desktop" package and reboot the machine and GUI desktop will be enabled for the Operating System. In this blog post my virtual machine is connected to the internet and hence I am able to use available pupblic repository for package installation, if in case internet is not available for the server/machine then we have configure the local/Server  repository for the installation. Follow the below steps for desktop package installation: After installation of dekstop package we are now able to login with GUI desktop environment

Oracle Applications R12.2 Installation on Linux using virtual box

Oracle E-Business suite R12.2 is released a month ago. I received too many requests from my followers to demonstrate this Installation. This is a step by step detailed article for Installing Oracle E-business suite R12,2 on Oracle Enterprise Linux 5.7 (64-bit). I've used oracle virtual box for Installing Linux. Note:  This Installation is demonstrated on virtual machine with 8GB RAM and Installation completed in 7 hours. I am not sure whether this Installation will work with less than this .  My Virtual Machine configuration: CPU    = 1 core RAM   = 8 GB HDD   =  380 GB Software's Required: 1) Oracle Virtual Box 2) Oracle Enterprise Linux 5.7 (64-bit) 3) Oracle E-Business suite R12.2 for LinuxX86-64-bit Installation Steps: Hardware requirements Create virtual machine and Install operating system Operating System pre-requisites Prepare Stage Area Install Oracle EBS R12.2 software Verify Installation 1. Hardware Requirement