Saturday, May 17, 2008

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 FORMAT FOR DEVICE TYPE disk TO '/u1/oradata/cf_ORCL_auto_%F';

where %F is mandatory and translates into c-IIIIIIIIII-YYYYMMDD-QQ being:

  • IIIIIIII the DBID
  • YYYYMMDD timestamp of the backup
  • QQ a sequence that starts with 00 and ends with FF



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 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 commands

  • LIST
  • REPORT




For catalog maintenance (Administration Workshop II 3-8)

  • CROSSCHECK
  • DELETE
  • CHANGE
  • LIST

0 comments: