2025. 11. 17. 10:17 오라클
RMAN 기본 명령어 몇개
### TO BACKUP THE CONTROLFILE USING RMAN:
run{
allocate channel dev1 type disk format 'c:\backup\%U';
backup current controlfile;
}
### TO CHECK THE BACKUP OF CONTROLFILE USING RMAN:
list backup of controlfile;
### TO RECOVER USING BACKUP CONTROLFILE: (startup nomount)
run {
allocate channel dev1 type disk;
restore controlfile;
alter database mount;
restore database;
recover database;
sql "ALTER DATABASE OPEN RESETLOGS";
}
### TO BACKUP ALL DATAFILES AND CONTROLFILE USING RMAN:
run {
allocate channel dev1 type disk;
backup full tag = 'full backup' database include current controlfile format = 'c:\backup\db_t%t_s%s_p%p';
release channel dev1;
}
### TO CHECK ALL BACKUP OF DATAFILES USING RMAN:
list backupset;
### TO RESTORE BECAUSE OF MISSING/CORRUPT FILE(S) (First MOUNT the database and run RMAN)
run {
allocate channel dev1 type disk;
restore database;
recover database;
}
### RESTORE UNTIL TIME
The 'SET UNTIL TIME' must match with the variable NLS_DATE_FORMAT.
Prior logging on RMAN set the NLS_DATE_FORMAT in the desired format.
For example:
If unix ===> export NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS';
If on windows nt ===> set this vaiable in the registery.
run {
set until time 'May 1 2000 08:00:00';
allocate channel dev1 type disk;
shutdown abort;
startup nomount;
restore controlfile;
alter database mount;
restore database;
recover database;
sql 'alter database open resetlogs';
}
### TO PURGE OBSOLETE BACKUPS:
RMAN> #REPORTS ANY BACKUP WITH MORE THAN 3 COPIES
report obsolete redundancy 3 device type disk;
RMAN> #USE THIS REPORT TO FILL IN THE XXXXX BELOW
report obsolete orphan;
RMAN> allocate channel for maintenance type disk;
allocate channel for delete type disk;
change backuppiece 'C:\BACKUP\xxxx' delete;
release channel;
RMAN> allocate channel for maintenance type disk;
allocate channel for delete type disk;
change datafilecopy 'C:\BACKUP\xxxx' delete;
release channel;
### TO BACKUP ALL ARCHIVE LOGS
run{
allocate channel dev1 type disk format 'c:\backup\%U';
backup archivelog all;
}
### TO REMOVE ALL ARCHIVE LOG FILES AFTER BACKUP UPDATE TO THIS LINE
backup archivelog all delete input;
### SKIP AN ARCHIVE LOG FILE THAT CAN NOT BE READ OR MANUALY DELETED UPDATE TO THIS LINE
backup archivelog skip inaccessible
### TO REMOVE ONE ARCHIVE LOG THAT YOU MANUALY DELETED AND NOW GET AN RMAN-6089 <= 8.0
allocate channel for delete type disk; or 'SBT_TAPE';
change archivelog 'path/filename' delete;
and/or
resync catalog;
### TO REMOVE ONE ARCHIVE LOG THAT YOU MANUALY DELETED AND NOW GET AN RMAN-6089 <= 8.1
allocate channel for maintenance type ....'
change archivelog <name> uncatalog
Note:
The channels for delete and maintenance do not require the run command enclosed in {}.
