RMAN backup script – example – logging output
Posted by John Hallas on March 20, 2008
To answer a question about writing the output from RMAN commands to a logfile I posted a copy of a shell script I use to the Oracle-L newsgroup. It is a script I use for testing which does explain the multiple RMAN commands, much of which are commented out.
I
#!/bin/ksh
export ORACLE_HOME=/u00/app/oracle/product/11.1.0/db_2
export ORACLE_SID=TEST1
export PATH=$PATH:$ORACLE_HOME/bin
export NLS_DATE_FORMAT=’DD-MON-YY HH24:MI:SS’
export DATE=$(date +%Y-%m-%d)
rman target backup_admin/xxxxxxx catalog rman/xxxxxxx@server msglog /export/backups/rman/11g/logs/rman_full_backup_db_online_TEST1_${DATE}.log <<EOF
#backup AS COMPRESSED BACKUPSET database ;
#backup AS COMPRESSED BACKUPSET archivelog all delete input ;
backup AS COMPRESSED BACKUPSET database plus archivelog delete input;
#backup AS COMPRESSED BACKUPSET database;
#backup database;
#backup archivelog all delete input;
#BACKUP INCREMENTAL LEVEL 0 TAG = WEEKLY DATABASE;
#delete noprompt force obsolete;
#Change archivelog all validate
exit;
EOF
exit
From the Oracle documentation I also found the following notes
Using RMAN with Command Files
A command file is a text file which contains RMAN commands as you would enter them at the command line. You can run the a command file by specifying its name on the command line. The contents of the command file will be interpreted as if entered at the command line. If the LOG command line argument is specified, RMAN directs output to the named log file. Command files are one way to automate scheduled backups through an operating system job control facility.
In this example, a sample RMAN script is placed into a command file called commandfile.rcv. You can run this file from the operating system command line and write the output into the log file outfile.txt as follows:
% rman TARGET / CATALOG rman/cat@catdb CMDFILE commandfile.rcv LOG outfile.txt
Directing RMAN Output to a Log File
When you run RMAN in command line mode, it sends the output to the terminal. If you specify the LOG option, then RMAN writes the output to a specified log file instead.
Output for currently executing RMAN jobs is also stored in the V$RMAN_OUTPUT view, which reads only from memory (that is, the information is not stored in the control file). The V$RMAN_STATUS view contains metadata about jobs in progress as well as completed jobs. The metadata for completed jobs is stored in the control file.
www.rmanbackup.com said
Thank you so much for sharing this precious information with us.
2010 in review « Oracle DBA – A lifelong learning experience said
[...] Posts ORA-19809: limit exceeded for recovery files – db_recovery_file_dest_size and archiver errorRMAN backup script – example – logging outputWhere has consistent=y gone when using Datapump exportPurging statistics from the SYSAUX [...]
Haftpflichtversicherung,Hausratversicherung,Versicherungsvergleich said
Haftpflichtversicherung,Hausratversicherung,Versicherungsvergleich…
[...]RMAN backup script – example – logging output « Oracle DBA – A lifelong learning experience[...]…
shahid ahmed said
Thank you very much sharing this script. It is really useful for all of us