Detailed and summary of RMAN commands common

Detailed and summary of RMAN commands commonly used
Zhuanzhai pooled for future use
This link: HTTPS: //blog.csdn.net/EVISWANG/article/details/50448370
http://blog.itpub.net/25904686/viewspace-742701/
HTTPS: //blog.csdn.net/zq9017197/article/details/6869579
https://www.cnblogs.com/polestar/archive/2013/02/06/2902598.html
--HQ_ display RMAN backups, and log
http: //blog.itpub.net/30126024/viewspace-2128114/

【输出日志】
[oracle@tiger script]$ cat rman_db.sh
exportORACLE_HOME=/u01/oracle/product/11.2.0.4
export ORACLE_SID=TIGER
rman target / cmdfile=/u01/rman/script/rman_db.rcv msglog=/u01/rman/script/rman_full_`date+%Y-%m-%d`.log
[oracle@tiger script]$

[Catalog]
1, registered copy
Cataog datafilecopy 'c: \ user01.bak';
2, registered backup piece
Cataog backuppiece 'c: \ demo_10.dbf';
3, registered a specific directory of all backup files
catalog start with 'c: \ BAK ';
. 4, cancellation of backup records
Change datafilecopy' C: \ user01.bak 'the uncatalog;
Change controlfilecopy' C: \ demo.ctl 'the uncatalog;
Change backuppiece' C: \ demo_10.bak 'the uncatalog;
. 5, archive log registered
catalog ARCHIVELOG '/u01/CCBPROD/oracle/oradata/archive/thread_2_seq_12307.2161.899944423';
cataloged Archived log
Archived log File name = / u01 / CCBPROD / Oracle / oradata / Archive / 9578 = thread_2_seq_12307.2161.899944423 recid the STAMP = 900 068 071

[Crosscheck]
crosscheck backup check all backup sets;
crosscheck backup of Database collation backup set of all data files;
crosscheck backup of TABLESPACE Users check the backup set for a particular table space;
crosscheck backup of backup sets datafile 4 collation specific data file;
crosscheck backup of backup set controlfile verification control file;
CROSSCHECK backup of SPFILE check SPFILE backup set;
CROSSCHECK backup of backup set archivelog sequence 3 collation archive logs;
CROSSCHECK copy check all image copy;
CROSSCHECK copy of Database check all data files image copy ;
CROSSCHECK copy of tABLESPACE Users check image copy of a particular table space;
CROSSCHECK copy of image copies datafile 6 collation specific data file;
CROSSCHECK copy of copies of the image archivelog sequence 4 collation archive logs;
image copy crosscheck copy of controlfile verification control file ;
CROSSCHECK Backup Tag = 'SAT_BACKUP';
crosscheck backup completed after 'sysdate - 2'
crosscheck backup completed between 'sysdate - 5' and 'sysdate -2 '
crosscheck backup device type sBT;
crosscheck archivelog all;
crosscheck archivelog like '%ARC00012.001'
crosscheck archivelog from sequence 12;
crosscheck archivelog until sequence 522;

expired: object does not exist on disk or tape. When a backup set is expired state, the backup set of all expired backup sheet is also in a state
available: the object is available. When a backup set is available, the backup of all backup sets also available in sheet
unavailabe: an object in an unusable state. When a backup set is unavailable, the backup of all backup sets in the sheet also is unavailable
NOTE: expired not equivalent to obsolette. Please refer to the difference between the two: Document

[Delete]
1, delete obsolete backup
delete obsolete; # Tip
delete noprompt obsolete; # not prompt
2, delete EXPIRED backup set
the Delete noprompt expired The Backup;
3, delete EXPIRED copy of
the Delete noprompt expired The Copy;
4, to delete a specific backup set
delete noprompt backupset 19;
5, delete specific backup sheet
delete noprompt backuppiece 'C: \ Test \ demo1.bak';
. 6, deletes all backup sets
delete noprompt backup; or
noprompt BACKUPSET delete;
. 7, delete specific image copies
delete noprompt datafilecopy 'c: \ test \ demo.bak '; delete the data file
delete noprompt controlfilecopy' c: \ test \ controlfile_bak.ctl '; delete the control file
delete noprompt archivelog' c: \ test \ arc.bak '; delete archived log
? delete noprompt force archivelog all completed before 'sysdate - 7';
8, an image delete all copies
Delete noprompt Copy;
. 9, after the backup objects erasing input
Backup ARCHIVELOG Delete All INPUT;
Backup BACKUPSET = 22 is the format 'C: \ Test \% u.bak' Delete INPUT;
10, expired The Delete All ARCHIVELOG; information is actual physical file synchronization and control files.

[Report]
physical structure RMAN> report schema report destination database;
the RMAN> Report need Backup Days = 3; report last 3 days the data files are not backed up;
the RMAN> Report need Backup Days 3 TABLESPACE Users; on USERS tablespace 3 days of data files are not backed up;
the RMAN> report need the incremental backup. 3; the number of incremental backup data recovery report file requires more than three times the data file;
the RMAN> report Database need backup Redundancy 2; report of the backup file is less than 2 parts All data files;
RMAN> report need Backup Redundancy = 2;
RMAN> report need Backup recovery window of 6 days; recovery requires reporting file a report over six days of archived log data files;
RMAN> report unrecoverable; reporting database of all non-recoverable data files;
RMAN> report obsolete redunndancy 2; report to back up more than 2 times the number of obsolete backup;
RMAN> report obsolete; report redundant backup;

[List]
lists the data file backup sets
RMAN> list backup set out in detail the backup;
RMAN> List expired The Backup; lists expired backup;
RMAN> list backup of Database; list backup set of all data files;
RMAN> list backup of tablespace user01; all data files listed in particular table space backup set;
the RMAN> List of controlfile listed backup control file backup set;
the RMAN> List of backup ARCHIVELOG All lists archive log backup set details;
the RMAN> List All ARCHIVELOG; List brief information archive log backup sets
RMAN> list backup of spfile listed SPFILE backup sets;
the RMAN> copy List of datafile image copy. 5 lists the data file;
the RMAN> copy List List of controlfile image copy control file;
the RMAN> List archive copy of archivelog all listed image copy log;
the RMAN> List database List of counterparts Incarnation / copy database are listed;
the RMAN> List Summary backup; overview of the available backup;

The RMAN> List Backup of datafile {n-| <the dir>}
the RMAN> List Copy of Archive from Time = 'SYSDATE -. 7';
the RMAN> List Backup of ARCHIVELOG from Sequence 1000 an until Sequence 1020.;
the RMAN> List BACKUPSET Tag = TAG20101014T155753;
represents backup
represents FULL
represented archive log
represents the incremental backup
Description backup state (X-A AVAILABLE EXPIRED)
MAN> List file backup by the backup by the backup types listed;
according to the data file backup, archive log backup control file backup, the backup server parameter file lists

【Show】
RMAN> show all;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
ARCHIVELOG DELETION POLICY the TO NONE the CONFIGURE; # default
the CONFIGURE the DEVICE the TYPE DISK the FORMAT the CHANNEL 'C: ...% d_DB_ U_%%% S_ P';
the CONFIGURE the SNAPSHOT CONTROLFILE the TO NAME 'D: \ the ORACLE \ PRODUCT \ 10.2.0 \ DB_1 \ DATABASE \ SNCFORCL.ORA '; # default

RMAN the Parameters for the configuration Database with the DB_UNIQUE_NAME PRODS are:
Notes: #default indicates that the configuration is still the initial default value. Back to the default configuration configure..clear.
1.CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
is used to determine which backup is no longer needed, it can be a total of three options, namely
the CONFIGURE The RETENTION POLICY the TO the RECOVERY WINDOW OF 7 DAYS;
the CONFIGURE The RETENTION POLICY the TO REDUNDANCY 5;
the CONFIGURE RETENTION POLICY tO NONE;
first recover window is enough to keep all of the backup, you can restore the system to the database at any time within the last seven days. Any database backups over the last seven days will be marked as obsolete.
The second redundancy is to maintain most recent five database backup can be restored, no more than 5 copies of the latest backup will be marked as redundancy. Its default value is 1 part.
The third does not require retention policies, clear will revert back to the default retention policies.
Generally the most secure method is to use a second retention policies
in which the first two are mutually exclusive relationship

2.CONFIGURE BACKUP OPTIMIZATION OFF; # default
is off by default, if you open the data file will rman backup and archiving files a kinds of optimization algorithms.
Theoretically, backup optimization only works for read-only table space or offline table space. Of course, the already backed up archive log files will be skipped.

3.CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
is to specify the type of device I / O operations to a hard disk or a magnetic tape, a hard disk DISK default value is
set the DEVICE tape the TYPE is the DEFAULT the TO the SBT the CONFIGURE;

4.CONFIGURE CONTROLFILE AUTOBACKUP is OFF; # default
forces the database backup files automatically control command after changing the database or perform a backup file structure, the default is off. After the control file and catalog avoid loss of control files can still be recovered.
When autobackup is set to on, rman to do any backup operation, the control file is automatically backed up.

5.CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '% F'; # default
is configured backup paths and backup control file format
, such as: configure controlfile autobackup format for device type disk to 'e: \ backupcontrol \% F'

6.CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
configuration database device type of parallelism. It determines the number of parallel channels.

7.CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
is configurable number of each backup copy of the database, oracle every backup parts can have multiple identical copies.
Whether to initiate a backup compound, specified by the specification of the i / o device generating position specified number of copies. The default is 1.
This configuration is used only for data files and archive files, and only when the channel is automatically assigned to take effect!

8.CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
log file is stored in the database provided device type

9.CONFIGURE MAXSETSIZE TO UNLIMITED; # default
backup set size maxsetsize
the configure maxsetsize to 1G | 1000M | 1000000K | Unlimited;
the configure maxsetsize the Clear;
configure the size of the backup set. Is generally configured maxpiecesize, backup piece to be limiting.

10.CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
configuration encrypted backup set. Can be specific to a particular table space:
the configure Encryption for the Users TABLESPACE ON;
if we execute the set encryption on indentified by think only, immediately following the backup created will need the password to restore normal

11.CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
specified encryption algorithm, there is a 'AES256'

The COMPRESSION the ALGORITHM 12.CONFIGURE 'the BASIC' the RELEASE AS OF 'the DEFAULT' OPTIMIZE the LOAD the FOR TRUE; # default
13.CONFIGURE ARCHIVELOG DELETION POLICY the TO NONE; # default
delete policy specifies the archive file, the default is none, that is: after completing the backup archive can be removed
, however, DG environment, DBA to ensure the success of the archive in standby receiving end and prior to the application, primary end always save the file
so, DG environment to: applied oN standby
14.CONFIGURE the tO SNAPSHOT CONTROLFILE NAME '/ u01 / CCBPROD / oracle / product / 11.2.0.4 / dbs / snapcf_PROD.f '; # default
stored snapshot file path and file name of the configuration control file, the snapshot files are generated during a backup, the files are read for controlling consistency
Further, CONFIGURE EXCLUDE fOR tABLESPACE <tablespace> [CLEAR]; this command is used to specify the table space is not backed up to the backup set, the command read-only table space is very useful.

15.CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'C : ...% d_DB_% u_% s_% p';
is the configuration and the backup path backup file backup format
CONFIGURE CHANNEL DISK CLEAR; for removing the above channel configuration
CONFIGURE EXCLUDE FOR TABLESPACE <tablespace> [CLEAR]; this command is used to specify the table space is not backed up to the backup set, the command read-only table space is very useful.
1. store the backup files to the specified path, such as E: \ backupb
Configure the format Channel Disk Device type 'E: \ backupb \% d_db_% u';
the latter is stored% d_db_% u format
2. We can also specify a separate control file stored in the other path: the E: \ backupcontrol
Configure Device for the format type controlfile AutoBackup Disk to 'E: \ backupcontrol \% F';
the latter is the% F storage format


Enter RMAN:
$ rman target sys / oracle @ orcl ?? - connect remotely to rman
$ rman target sys / oracle @ orcl @ backup_db.ram ?? - rman remotely connect to and execute the specified script
$ rman target sys / oracle @ orcl cmdfile = backup_db.ram ?? - rman and execute remotely connect to the specified script
$ rman target / log rman.log ?? - recording the output of rman
RMAN> @ backup_db.ram ?? --rman which executes the script
or
/ u01 / oracle / product / 10 / u01 / oracle / product / 10.2.0 / bin / rman target system / oracle @ ora10g (/) msglog = / u01 / rmanbak / bakl1.log cmdfile = / u01 / rmanbak / bakl0

Backup command:
the RMAN> Database Backup the format '... /% D_ the U-%'; ?? - backup database and specify a backup path
RMAN> backup database; ?? - database backup
RMAN> backup database include current controlfile plus archivelog delete all input ;? - backup data, control files, archive logs
RMAN> backup incremental level 0 database; ?? - differential incremental backup of the database
RMAN> backup incremental level 0 cumulative database ; ?? - cumulative incremental backup of the database
RMAN> backup as compressed backupset database; ?? - compressed backup database
RMAN> backup database include current controlfile; ?? - database backup and a backup control file
RMAN> backup tablespace users; ?? - backup table space
RMAN> backup datafile n; ?? - backing up data files
RMAN> backup datafiel '/opt/oracle/oradata/orcl/users01.dbf'; ?? - backing up data files
RMAN> backup current controlfile; ?? - backup control file
RMAN> backup current controlfile plus archivelog; ?? - backup control file and archived and then archive log backup
RMAN> backup archivelog all; ?? - Backup archive logs
RMAN> backup archivelog all delete all input ; ?? - Backup archive logs and delete
RMAN> backup spfile; ?? - backup parameter file
RMAN> backup backupset all; ?? - backup all backup sets
RMAN> backup backupset n; ?? - backup designated backup set

Restore, the restore command:
the RMAN> Restore Database; ?? - Restore Database
RMAN> restore tablespace users; ?? - reduction tablespace
RMAN> restore datafile n; ?? - restore data files
RMAN> restore archivelog sequence between 10 and 20; ?? - restore archived logs
RMAN> restore controlfile from autobackup; ?? - restore the control file
RMAN> restore spfile to '/tmp/spfile.ora' from autobackup; ?? - reduction parameter file
RMAN> recover database ; ?? - restore the database
RMAN> recover tablespace users; ?? - recovery tablespace
RMAN> recover datafile n; ?? - recover data files
RMAN> restore validate database; ????? - verification database recoverability of
RMAN> restore validate controlfile; ?? - verification control file recoverability
RMAN> restore validate spfile; ??????? - verification parameter file recoverability

View backup set command:
RMAN> List Backup; ?? - database lists all of the backup sets
RMAN> list backup of database; ?? - Check database backup sets
RMAN> list backup of tablespace users; ?? - View tablespace backup set
RMAN> list backup of datafile n; ?? - view the backup data file
RMAN> list backup of controlfile; ?? - View control file backup set
RMAN> list backup of archivelog all; ?? - View archive log backup sets
RMAN> list archivelog all; ?? - View all current archive logs
RMAN> list expired backup; ?? - lists all invalid backup?

Manage backup sets command:
RMAN> CROSSCHECK Backup; ?? - Check all backup sets
RMAN> crosscheck archivelog all; ?? - Check all archived files
RMAN> delete [noprompt] obsolete; ?? - delete expired backup
RMAN> delete expired backup; ?? - remove invalid backup
RMAN> delete expired archivelog all ;? - delete all invalid archive files
RMAN> delete backupset 1; ?? - delete the specified backup
RMAN> delete backup; ?? - delete all backup
RMAN> change backupset 3 unavailable; ?? - 3 change backup set invalid
RMAN> change backupset 3 available; ???? - change backup set 3 valid
RMAN> change backup of controlfile unavailable; ?? - change control file is invalid
RMAN> change backup of controlfile available; ???? - change to the effective control file
RMAN> report schema; ?? - view the structure of the database backup
RMAN> report need backup; ?? - Check it needs to be backed file
RMAN> report need backup tablespace system;?? - Check whether the specified table space backup
RMAN> report obsolete; ?? - View expired backup

Guess you like

Origin www.cnblogs.com/ritchy/p/11851499.html