Amazon books

Friday, February 14, 2014

Creating a simple RMAN Backup Script to clone an instance to another environment (TEST, HOMOLOG, etc)

You have many ways to clone your database. This example is a simple backup that I used to use when I want to clone a database to a test environment (I prefer using physical standby method or the 11g from ACTIVE that you don't need a backup).

See these example scripts below:


vi backup_for_HML.sh
rman target / nocatalog @/backup/SIGE_BKP/scripts/BKP_for_HML.rcv log /backup/SIGE_BKP/scripts/log/BKP_for_HML.log "append"

vi backup_for_HML.rcv
run {
  allocate channel dsk1 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';
  allocate channel dsk2 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';
  allocate channel dsk3 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';
  allocate channel dsk4 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';
  allocate channel dsk5 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';
  allocate channel dsk6 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';
  allocate channel dsk7 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';
  allocate channel dsk8 device type disk format '/backup/SIGE_BKP/bkp/BKP_for_HML_SIGE_%d_%U.bkp';

  backup as  backupset full database plus archivelog;
  sql 'alter system switch logfile';
  sql 'alter system checkpoint';
  sql 'alter system switch logfile';
  sql 'alter system switch logfile';
  backup archivelog all format '/backup/SIGE_BKP/bkp/bkp_archives_for_HML.bkp';
  backup current controlfile formta '/backup/SIGE_BKP/bkp/ctl_for_HML.ctl';

  release channel dsk1;
  release channel dsk2;
  release channel dsk3;
  release channel dsk4;
  release channel dsk5;
  release channel dsk6;
  release channel dsk7;
  release channel dsk8;
}

################################################################
Now you run your backup:

nohup sh backup_for_HML.sh > backup_for_HML.out &




Best Regards,
Paulo Portugal

No comments:

Post a Comment