El script backup_caliente_local_RMAN.sh se ha de llamar con los parámetros:
backup_caliente_local_RMAN.sh SID_BBDD DIR_DESTINO
Donde
SID_BBDD es el SID de la base de datos Oracle a copiar.
DIR_DESTINO es el directorio destino del backup (ej. /u01/backups) donde se almacenará el backup en caliente comprimido RMAN de la base de datos.
Se trata de un backup en caliente, es decir, la base de datos puede permanecer operativa mientras se realiza el backup, para ello, la base de datos debe estar en modo Archivelog.
#!/bin/sh
. $HOME/.profile
SID=$1
DEST=$2
RMAN_LOG=$HOME/backup_rman/logs/backup-caliente-local-RMAN_$SID.log
RMAN=$ORACLE_HOME/bin/rman
# Creamos el fichero de log
echo >> $RMAN_LOG
echo ==== Fecha Inicio: `date` ==== >> $RMAN_LOG
echo >> $RMAN_LOG
# Comandos RMAN para la base de datos
ORACLE_SID=$SID
export ORACLE_SID
$RMAN target / nocatalog msglog $RMAN_LOG append <<EOF
set encryption on for all tablespaces algorithm 'AES128' identified by "password_encriptacion" only;
RUN {
allocate channel disk1 device type disk format '$DEST/data_%U' maxpiecesize 20 G;
allocate channel disk2 device type disk format '$DEST/data_%U' maxpiecesize 20 G;
backup filesperset = 5 keep until time 'SYSDATE+31' logs as COMPRESSED BACKUPSET tag '%TAG' database include current controlfile;
release channel disk1;
release channel disk2;
allocate channel disk1 device type disk format '$DEST/ctl_%U' maxpiecesize 20 G;
backup current controlfile;
release channel disk1;
allocate channel disk1 device type disk format '$DEST/spfile_%U' maxpiecesize 20 G;
backup spfile;
release channel disk1;
}
allocate channel for maintenance device type disk;
CROSSCHECK BACKUP;
CROSSCHECK archivelog all;
delete noprompt obsolete ;
delete noprompt EXPIRED BACKUP;
delete noprompt expired archivelog all;
release channel;
run {
# Generamos el ultimo fichero de redo log archivado
sql 'alter system archive log current';
allocate channel disk1 device type disk format '$DEST/arch_%U' maxpiecesize 20 G;
backup filesperset = 5 as COMPRESSED BACKUPSET tag '%TAG' archivelog all not backed up;
release channel disk1;
}
EOF
RESULTADO=$?
if [ "$RESULTADO" = "0" ]
then
LOGMSG="Backup caliente local RMAN para la bbdd $SID sobre $DEST terminado correctamente"
else
LOGMSG="Backup caliente local RMAN para la bbdd $SID sobre $DEST terminado con ERROR"
fi
MES=`date +%m`; export MES
DIA=`date +%d`; export DIA
ANO=`date +%Y`; export ANO
FECHA=$ANO$MES$DIA
USR_PWD="sys/sys as sysdba"
sqlplus $USR_PWD <<EOF
alter system checkpoint;
alter database backup controlfile to trace as '$DEST/control-$SID.ctl';
create pfile='$DEST/spfile-$SID.txt' from spfile;
exit;
EOF
mv $DEST/control-$SID.ctl $DEST/control-$SID.ctl.$FECHA
# Finalizamos el fichero de log
echo >> $RMAN_LOG
echo ==== $LOGMSG: `date` ==== >> $RMAN_LOG
exit $RESULTADO
No hay comentarios:
Publicar un comentario