Forum Stats

  • 3,770,332 Users
  • 2,253,095 Discussions
  • 7,875,405 Comments

Discussions

RMAN bash example (simple but effective) for production DB 18c

orasiya
orasiya Member Posts: 427 Bronze Badge
edited Jul 10, 2020 3:37PM in Recovery Manager (RMAN)

Dear Friends,

I need bash example  (good & effective  rman bash example) of rman backup for my production database , simple but effective that

1-  it does level 0 backup of database  including the  control file , spfile every  week on saturdays

2- it does incremental level 1 backup everyday

3- it does archivelog backup everyday

for review

----------------------------- level 0run{allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/FULL_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/FULL_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/FULL_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/FULL_%U';.....backup as backupset incremental level 0 section size 32g database tag 'RMAN/FULL_L0' plus archivelog not backed up 2 times;#control file backupallocate channel ch_cntl device type disk format '/ZFS/DB_PRO/disk1/cf_%U';backup as backupset CURRENT CONTROLFILE channel ch_cntl;#spfile backupallocate channel ch_sp  device type disk format '/ZFS/DB_PRO/disk1/sp_%U';backup as backupset SPFILE channel ch_sp;DELETE NOPROMPT OBSOLETE;}----------------------------- level 1run{allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/INC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/INC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/INC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/INC_%U';.....          backup as backupset incremental level 1 section size 32g database tag 'RMAN/LEVEL_L1' plus archivelog not backed up 2 times;          DELETE NOPROMPT OBSOLETE;          }        ------------------------------          -------------------- archivelog backup run{allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/ARC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/ARC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/ARC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/ARC_%U';backup archivelog all not backed up 2 times;delete noprompt archivelog until time '(sysdate-30)'; }--------some rman configuration setting RMAN> show all;RMAN configuration parameters for database with db_unique_name DB_PRO are:CONFIGURE RETENTION POLICY TO REDUNDANCY 5;CONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ZFS/DB_PRO/disk1/auto/%F';CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # defaultCONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE ENCRYPTION FOR DATABASE OFF; # defaultCONFIGURE ENCRYPTION ALGORITHM 'AES128'; # defaultCONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # defaultCONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO '+REC1/DB_PRO/snapcf_DB_PRO.f';

Answers

  • EdStevens
    EdStevens Member Posts: 28,533 Gold Crown
    edited Jul 10, 2020 3:37PM
    orasiya wrote:Dear Friends,I need bash example (good & effective rman bash example) of rman backup for my production database , simple but effective that1- it does level 0 backup of database including the control file , spfile every week on saturdays2- it does incremental level 1 backup everyday3- it does archivelog backup everydayfor review----------------------------- level 0run{allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/FULL_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/FULL_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/FULL_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/FULL_%U';.....backup as backupset incremental level 0 section size 32g database tag 'RMAN/FULL_L0' plus archivelog not backed up 2 times;#control file backupallocate channel ch_cntl device type disk format '/ZFS/DB_PRO/disk1/cf_%U';backup as backupset CURRENT CONTROLFILE channel ch_cntl;#spfile backupallocate channel ch_sp device type disk format '/ZFS/DB_PRO/disk1/sp_%U';backup as backupset SPFILE channel ch_sp;DELETE NOPROMPT OBSOLETE;}----------------------------- level 1run{allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/INC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/INC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/INC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/INC_%U';..... backup as backupset incremental level 1 section size 32g database tag 'RMAN/LEVEL_L1' plus archivelog not backed up 2 times; DELETE NOPROMPT OBSOLETE; } ------------------------------ -------------------- archivelog backup run{allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/ARC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/ARC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk1/ARC_%U';allocate channel ch01 device type disk format '/ZFS/DB_PRO/disk2/ARC_%U';backup archivelog all not backed up 2 times;delete noprompt archivelog until time '(sysdate-30)'; }--------some rman configuration setting RMAN> show all;RMAN configuration parameters for database with db_unique_name DB_PRO are:CONFIGURE RETENTION POLICY TO REDUNDANCY 5;CONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ZFS/DB_PRO/disk1/auto/%F';CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # defaultCONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE ENCRYPTION FOR DATABASE OFF; # defaultCONFIGURE ENCRYPTION ALGORITHM 'AES128'; # defaultCONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # defaultCONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO '+REC1/DB_PRO/snapcf_DB_PRO.f';

    Why do you allocate different directories for the level 0 backup than for the level 1 backups? This is needless complexity.

    YOu don't need separate run blocks for archivelogs and/or controlfile/spfile.  This is needless complexity

    I accomplish everything you want with a single shell script.  Here's the core of it:

    #!/bin/shORACLE_SID=$1inclvl=$2logfile=$3
    ORAENV_ASK=NOsource oraenvrman target /  <<EOF >> $logfileset echo ondelete force noprompt obsolete;backup as compressed backupset incremental level $inclvl database tag ${ORACLE_SID}_db_bkup plus archivelog delete all input /tag ${ORACLE_SID}_arch_bkup;
    list backup;
    EOF