Search This Blog

Tuesday, December 15, 2015

RMAN Backup Scripts - Realtime Usefull

Simple backup script

$rman target sys/manager@toprod @offbak.rman

offbak.rman
run{
shutdown immediate;
startup mount;
allocate channel c1 type disk;
backup database format '/u01/bkp/fullbak.bus';
alter database open;
}

One more simple RMAN script

RMAN> RUN{
# backup the database to disk
ALLOCATE CHANNEL c1 TYPE DISK;
ALLOCATE CHANNEL c2 TYPE DISK;
ALLOCATE CHANNEL c3 TYPE DISK;
#backup the whole db
BACKUP
TAG whole_database_open
FORMAT '/u01/oradata/backups/db_%t_%s_p%p'
DATABASE;
# switch the current log file
SQL 'alter system archive log current';
#backup the archived logs
BACKUP
ARCHIVELOG ALL
FORMAT '/u11/oradata/backups/al_%t_%s_p%p';
# backup a copy of the control file
BACKUP
CURRENT CONTROLFILE
TAG = cf1
FORMAT '/u12/oradata/backups/cf_%t_%s_p%p';
RELEASE channel c1;
RELEASE channel c2;
RELEASE channel c3;
}


Real time backup script for a tape (with media manager)

create script weekly_full_tape{
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
SEND 'NB_ORA_CLIENT=175.16.34.25,NB_ORA_POLICY=DMS_OraDB_rman';
BACKUP
INCREMENTAL Level=0
FORMAT 'db_df_%U_%t'
DATABASE;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
SEND 'NB_ORA_CLIENT=175.16.34.25,NB_ORA_POLICY=DMS_OraDB_rman';
BACKUP
FORMAT 'db_arc_%U_%t'
ARCHIVELOG ALL;
RELEASE CHANNEL ch00;
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
SEND 'NB_ORA_CLIENT=175.16.34.25,NB_ORA_POLICY=DMS_OraDB_rman';
BACKUP
FORMAT 'db_cf_%U_%t'
CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;}


Real time daily backup script incremental

create script daily_inc_disk{
allocate channel c1 device type disk format '/home/oracle/bkp/db_df_%U_%t';
allocate channel c2 device type disk format '/home/oracle/bkp/db_df_%U_%t';
allocate channel c3 device type disk format '/home/oracle/bkp/db_df_%U_%t';
backup incremental level 1 database;
backup archivelog all format '/home/oracle/bkp/arc_%d_%u_%s_%T' not backed up 2 times;
delete noprompt archivelog UNTIL TIME 'sysdate-6' backed up 1 times to device type disk;
release channel c1;
release channel c2;
release channel c3;}


Real time backup script (Weekly, Full, Incremental)

create script weekly_full_disk{
allocate channel c1 device type disk format '/home/oracle/bkp/db_df_%U_%t';
allocate channel c2 device type disk format '/home/oracle/bkp/db_df_%U_%t';
allocate channel c3 device type disk format '/home/oracle/bkp/db_df_%U_%t';
backup incremental level 0 database;
backup archivelog all format '/home/oracle/bkp/arc_%d_%u_%s_%T' not backed up 2 times;
delete noprompt archivelog UNTIL TIME 'sysdate-6' backed up 1 times to device type disk;
release channel c1;
release channel c2;
release channel c3;}

No comments:

Post a Comment