orangewise (nerdy stuff)

January 15, 2005

Backup on Windows: RMAN

Filed under: oracle — orangewise @ 7:48 AM

Set database in archivelog mode:

shutdown;
startup mount;
alter database archivelog;
alter system set log_archive_start=true scope=spfile;
alter database open;

Switch logfile:

alter system switch logfile

Archive location:

archive log list

Start RMAN session:

set ORACLE_SID=ronald10
c:oracleora9201binrman nocatalog target ronald@ronald10

Once a week level 0 (incremental_level_0.rcv):

# baseline backup
run {
  allocate channel c1 type disk;
    backup
    incremental level = 0
    format='c:orabckincr_level_0_%u'
    database
    include current controlfile
    spfile
    plus archivelog
  ;
}

Level 1 (incremental_level_1_cumulative.rcv):

# backup all datablocks since last level 0
run {
  allocate channel c1 type disk;
  backup
    incremental level = 1
    format='c:orabckincr_level_1_%u'
    cumulative
    database
    include current controlfile
    spfile
    plus archivelog
  ;
}

Level 2 (incremental_level_2_cumulative.rcv):

# backup all datablocks since last level 1
run {
  allocate channel c1 type disk;
  backup
    incremental level = 2
    format='c:orabckincr_level_2_%u'
    cumulative
    database
    include current controlfile
    spfile
    plus archivelog
  ;
}

set retention policy to 2 (keep 2 backups):

CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

Report obsolete files (obsolete_disk.rcv):

report obsolete device type disk;

Delete obsolete files (obsolete with regards to your retention policy):

delete obsolete;

Remove obsolete backups (check obsolete_disk_delete.rcv):

# for maintenance and delete do not use run {}
  allocate channel for delete type disk;
  change backuppiece 1 delete;
# change datafilecopy '' delete;
# change controlfilecopy '' delete;
  release channel;
# for archive logs:
allocate channel for maintenance type disk;
change archivelog all crosscheck;
release channel;

Crosscheck: checks if files are ok, if not available, there are deleted (crosscheck.rcv):

allocate channel for maintenance type disk;
crosscheck backup of database;
delete expired backup;
release channel;

Backup archive logs (archive_log_bac.rcv):

###TO BACKUP ALL ARCHIVE LOGS
run{
 allocate channel dev1 type disk format 'c:orabckarch%U';
 backup archivelog all
   skip inaccessible
   delete input
  ;
 }

Restore database to its original location:

start new rman session...
shutdown immediate;
startup mount;
run {
     allocate channel ch1 type disk;
     allocate channel ch2 type disk;
     allocate channel ch3 type disk;
     restore database;
     recover database;
}
alter database open;

Restore and recover tablespace to its original location:

start new rman session...
shutdown immediate;
startup mount;
report schema; # to get tablespace name
run {
     allocate channel ch1 type disk;
     allocate channel ch2 type disk;
     restore tablespace tablespace_name;
     recover tablespace tablespace_name;
}
alter database open;
Your Ad Here




Powered by WordPress