Oracle RMAN Commands and Scripts Examples
Full Backup
Full database plus archivelog backup on file system
RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure channel device type disk format 'D:\Oracle\Admin\db2\Backup%d_DB_%u_%s_%p';
RMAN> run {
2> backup database plus archivelog;
3> delete noprompt obsolete;
4> }
#*** Weekly full database plus archivelog backup Script on disk
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_DATABASE'
FORMAT '/srv/oradata/backups/weekly_database_%d_t%t_s%s_p%p' or ’Path’
DATABASE;
#*** Daily full database backup Script on disk
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 1 CUMULATIVE
DEVICE TYPE DISK
TAG = 'DAILY_COMULATIVE_DATABASE'
FORMAT '/srv/oradata/backups/daily_comulative_database_%d_t%t_s%s_p%p' or ‘Path’
DATABASE;
#*** Maintenance steps
CROSSCHECK COPY;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
Restore & Recover The Whole Database
If the control files and
online redo logs are still present a whole database recovery can be achieved by
running the following script:
run {
shutdown immediate; # use abort if this fails
startup mount;
restore database;
recover database;
alter database open;
}
SAMPLE RMAN SCRIPTS
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
set newname for datafile 1 to
'/extracts1/DB01_temp/system_01a.dbf';
set newname for datafile 2 to
'/extracts1/DB01_temp/rbslrg01.dbf';
set newname for datafile 3 to
'/extracts1/DB01_temp/tools01.dbf';
set newname for datafile 4 to
'/extracts1/DB01_temp/temp01.dbf';
set newname for datafile 5 to
'/extracts1/DB01_temp/usersdata01.dbf';
set newname for datafile 6 to
'/extracts1/DB01_temp/usersidx01.dbf';
set newname for datafile 7 to
'/extracts1/DB01_temp/oem_repository.dbf';
set newname for datafile 8 to
'/extracts1/DB01_temp/users01.dbf';
restore database ;
switch datafile all;
}
-- If archivelogs are
backed up by RMAN, use RMAN to restore them:
rman target / nocatalog
allocate channel ch1 type disk;
run {
restore archivelog from time = 'date-of-start-of-backup';
}
exit
rman target / nocatalog
allocate channel ch1 type disk;
run {
restore database;
}
exit
Hot Backup
Hot backups using RMAN are
very simple. There is no need to alter the tablespace or database mode.
run {
allocate channel ch1 type disk format 'd:\oracle\backup%d_DB_%u_%s_%p';
backup database;
backup archivelog all;
release channel ch1;
}
Tags: Backup, Oracle Database, RMAN
Subscribe to:
Post Comments (Atom)
Share your views...
0 Respones to "Oracle RMAN Commands and Scripts Examples"
Post a Comment