bash scripts – Backup Cold RAC

Cuando trabajamos con RAC es importante el tema de los backups:

Siempre trabajo con RMAN y backup hot, pero en algunos clientes por tema de costo de hardware, precisamente de storage, dejan de lado el archiving y trabajan en modo NOARCHIVELOG. Para esos casos armer este script para ambientes RAC y backup COLD.

ATENCION: Recuerden siempre hacer una prueba en un ambiente copia de producción y adecuarlo a las necesidades de cada uno, una vez que logramos lo que queremos o necesitamos, y verificando que no ocacionara problemas lo pasamos a producción.

#!/bin/bash
#========================================================================================
#                               BACKUP DAILY COLD RAC                                   =
#                                                                                       =
# Ejecuta un COLD RAC backup de la base.                                                =
# Dejando los archivos de backup y su log en $PATH                                      =
# Nomenclatura de archivos AAAAMMDD_BASE_PRE_DBID########_seq_pieza_tipoarch            =
# Nomenclatura TAG RMAN :                                                               =
#                                                                                       =
#                                                                                       =
# Auth: Juan Andres Mercado                                                             =
#========================================================================================
#=========================================================================
# DAYLY SCRIPT BACKUP OFFLINE $BASE (ExECUT from UNIX server)
# /usr/local/bin/
#=========================================================================

# Convierte a minuscula
toLower() {
echo $1 | tr "[:upper:]" "[:lower:]"
}

PARAM=$(toLower $1)
HOMEBKP=      # PATH BACKUP
HOME_ENV=     # Enviroment path /home/oracle/bin
MAIL=         # username eg. dana@domain.com
DOMAIN=       # user@domain.com user@homeilnux.com

#=========================================================================
# set the enviroment variables
#=========================================================================

. $HOME_ENV/$PARAM.sh

BASE=$1
BASE=`echo ${BASE} | sed -e 's/[0-9]$//g'`
TAG=${BASE}_$(date +"%Y%m%d.%H%M")
HOMELOG=$HOMEBKP

srvctl stop database -d $BASE

#=========================================================================
# backup base RMAN
#=========================================================================

rman target / LOG=$HOMELOG/$TAG.log <
connect catalog rman/*****@catrman
startup mount;
run {
allocate channel oem_backup_disk1 type disk ;
allocate channel oem_backup_disk2 type disk ;
backup as COMPRESSED BACKUPSET tag '$TAG' database format '${HOMEBKP}/%T_%d_DBID%I_s%s_p%p_dbf';
backup as COMPRESSED BACKUPSET tag '$TAG' current controlfile format '${HOMEBKP}/%T_%d_DBID%I_s%s_p%p_ctl';
backup as COMPRESSED BACKUPSET tag '$TAG' archivelog from time 'sysdate-1' format '${HOMEBKP}/%T_%d_DBID%I_s%s_p%p_arc';
release channel oem_backup_disk1;
release channel oem_backup_disk2;
}
restore validate database;
SHUTDOWN IMMEDIATE;
quit;
EOF

srvctl start database -d $BASE
srvctl start service -d $BASE

RC=$?

if [[ $RC -ne 0 ]]
then
RC=99
fi

exit $RC

#=========================================================================
# send the log
#=========================================================================
mail ${MAIL}@${DOMAIN} -s "Finish Cold Backup ${BASE} " < $HOMELOG/$TAG.log

5 thoughts on “bash scripts – Backup Cold RAC

  1. After looking into a number of the blog posts on
    your site, I honestly like your technique of
    writing a blog. I saved as a favorite it to my bookmark webpage list and
    will be checking back in the near future. Please visit my website as well and tell me what
    you think.

    Like

  2. I am truly glad to read this blog posts which carries lots of helpful information, thanks for providing such information.
    Saving it Mp3 songs is arguably one particular most popular method of
    applying for music.

    Like

  3. A person necessarily help to make significantly posts I’d state. That is the very first time I frequented your website page and so far? I amazed with the analysis you made to make this particular publish extraordinary. Wonderful task!

    Like

  4. Hello to all, as I am really keen of reading this blog’s post to be updated on a regular basis. It contains pleasant material.

    Like

  5. Podra decirse que no estoy completamente de
    acuerdo con la forma en que se dice, sin embargo si estoy deacuerdo el fondo.
    Bien hecho

    Like

Comments are closed.