RMAN commands
To enable control file autobackup
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
To change the default format for autobackup file name
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP
2> FORMAT FOR DEVICE TYPE disk
3> TO '/u1/oradata/cf_ORCL_auto_%F';
where %F is mandatory and translates into c-IIIIIIIIII-YYYYMMDD-QQ being:
IIIIIIIIthe DBIDYYYYMMDDtimestamp of the backupQQa sequence that starts with00and ends withFF
Use the SHOW command to list current settings
RMAN> SHOW CONTROLFILE AUTOBACKUP FORMAT; RMAN> SHOW EXCLUDE; RMAN> SHOW ALL;
Use the CLEAR command to reset any persistent settings to its default value:
RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR; RMAN> CONFIGURE MAXSETSIZE CLEAR; RMAN> CONFIGURE DEFAULT DEVICE TYPE CLEAR;
Configure the default device type for automatic channel allocation
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;
or manually allocate a channel
RMAN> RUN {
2> ALLOCATE CHANNEL c1 DEVICE TYPE disk;
3> BACKUP DATAFILE '/u0/oradata/user01.dbf';
4> }
Configure parallelism
RMAN> CONFIGURE DEVICE TYPE disk PARALLELISM 3;
Specify the maximum backup piece size
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2G;
Format the name of the generated backup files
RMAN> RUN {
2> ALLOCATE CHANNEL d1 DEVICE TYPE disk
3> FORMAT '/disk1/backups/%U';
4> BACKUP DATABASE PLUS ARCHIVELOG; }
Some backup options (more on Administration Workshop II 3-9)
RMAN> BACKUP device type disk tag '%TAG' database
2> include current controlfile;
RMAN> BACKUP database plus archivelog;
RMAN> BACKUP datafile '/u0/oradata/user01.dbf';
RMAN> BACKUP AS BACKUPSET TABLESPACE hr_data;
(AS BACKUPSET can be omitted if RMAN is configured in mode BACKUPSET)
After a online backup, remember to archive current redo logs using:
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
or all archive logs:
SQL> ALTER SYSTEM ARCHIVE LOG ALL;
or a specific redo group:
SQL> ALTER SYSTEM ARCHIVE LOG GROUP n;
More on backups at http://www.stanford.edu/dept/itss/docs/oracle/9i/server.920/a96519/backup.htm
See backup constraints at Administration Workshop II 3-10
See parallel backup commands at Administration Workshop II 3-11
To create a clone database or a standby database from backups of the target database
RMAN> DUPLICATE database to auxiliaryDb;
To flashback a database
RMAN> FLASHBACK DATABASE
2> TO TIME = TO_DATE
3> ('06/25/03 12:00:00','MM/DD/YY HH:MI:SS');
after you have performed flashback database you should remember to reset logs:
SQL> ALTER DATABASE RESETLOGS;
To restore/recover
RMAN> RESTORE/RECOVER database; RMAN> RESTORE/RECOVER tablespace; RMAN> RESTORE/RECOVER datafile;
Reporting command LIST (Administration Workshop II 3-28 )
RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST BACKUP OF DATAFILE 2> '/db01/ORADATA/u03/users01.dbf'
List backup sets and copies of any data file in a specified tablespace:
RMAN> LIST COPY OF TABLESPACE "SYSTEM";
List backup sets and copies containing archive logs for a specified range:
RMAN> LIST COPY OF DATABASE ARCHIVELOG 2> FROM TIME='SYSDATE -7';
Reporting command REPORT (Administration Workshop II 3-29)
What is the structure of the datgabase?
RMAN> REPORT SCHEMA;
Which files need to be backed up?
RMAN> REPORT NEED BACKUP ...;
Which backups can be deleted?
RMAN> REPORT OBSOLETE;
Which files are not recoverable because of unrecoverable operations?
RMAN> REPORT UNRECOVERABLE ...;
For catalog maintenance (Administration Workshop II 3-8 )
CROSSCHECKDELETECHANGELIST
RMAN command-line arguments
(Administration Workshop II 2-27)
First set the ORACLE_SID env
$ export ORACLE_SID=orcl
Writing RMAN output to a log file
$ rman TARGET sys/oracle LOG=$HOME/oradata/u03/rman.log APPEND
Executing a command file when RMAN is invoked
$ rman TARGET sys/oracle CMDFILE=$HOME/scripts/my_rman_script.rcv
Establishes database connections on RMAN startup (both TARGET and CATALOG DBs)
$ rman TARGET sys/oracle@orcl CATALOG rman/rman@rcat
Note: NOCATALOG is the default mode (rman will use the control file as rman repository) unless a CATALOG database is specified.
Administration Workshop II. 2-16. Monitoring the Flash Recovery Area evolution with EM
Go to Enterprise Manager -> Related Links -> All metrics. Click on Recovery Area link then again on the percentage number to see the chart.
Administration Workshop II. 2-5. RMAN Performance Enhancements
- Automatic parallelization of backup, restore, and recovery operations
- No generation of extra redo during online database backups
- Backups that are restricted to limit the number of reads per file per second to avoid interfering with OLTP work
- The use of multiplexing, which can prevent flooding of any one file with reads and writes while still keeping a tape drive streaming
Administration Workshop II. 2-5. Use RMAN to detect block corruption
You can use RMAN to detect block corruption. The information relating to the block corruption that is detected during backup can be obtained by using the V$BACKUP_CORRUPTION and V$COPY_CORRUPTION dynamic views.
Administration Workshop II. 2-14. Using a Flash Recovery Area with RMAN
Flash Recovery Area simplifies managing disk space and files related to backup and recovery:
- When the flash recovery area is used, RMAN automatically uses Oracle Managed Files (OMF) for its backup files.
- Each time RMAN creates a file in the flash recovery area, the Oracle database updates the list of files that are no longer required on disk. When a file needs to be written into the flash recovery area and space is not available for that file, the Oracle database deletes a file that is on the obsolete files list and writes a notification to the alert log.
- A warning is issued when the flash recovery area experiences space pressure or is low on free space because there are no files that can be deleted from the flash recovery area. To resolve the problem, you can:
- add disk space
- back up your files to a tertiary device
- delete the files from the flash recovery area using RMAN
- or change the RMAN retention policy.The flash recovery area is configured by setting the DB_RECOVERY_FILE_DEST initialization parameter. The DB_RECOVERY_FILE_DEST_SIZE parameter specifies its size.
17-7. Flashback Database: Reducing Restore Time
With Flashback Database, the time to recover a database is now proportional to the number of changes that need to be backed out (and not to the size of the database) because you do not have to restore data files.
The Oracle database periodically logs “before images” of data blocks in the Flashback Database logs. Block images can be reused to quickly back out the data file changes to any time at which flashback logs are captured just before the desired target time. Then, changes from the redo log files are applied to fill in the gap (since we only have periodic images so the gaps are filled with redo log).
Flashback Database can be applied to NOLOGGING operations such as direct load inserts (Administration Workshop II 6-29).
An alternative to FLASHBACK DATABASE is to create a Guaranteed Restore Point (Administration Workshop II 6-29). The latter does not require flashback logging to be enabled in your database and can return your database to its state at the specified SCN:
SQL> CREATE RESTORE POINT before_load 2> GUARANTEE FLASHBACK DATABASE;
16-8. Loss of a Redo Log File
Database Control does not allow you to clear a log group that has not been archived. Doing so breaks the chain of redo information. If you must clear an unarchived log group, you should immediately take a full backup of the whole database. Failure to do so may result in a loss of data if another failure ocurrs.