BACKUP FULL DISK
connect target rman/@letodb;
run {
ALLOCATE CHANNEL ch00 TYPE DISK FORMAT '/u03/backup/rman/%d_%s_%p_%T_%U.bck';
ALLOCATE CHANNEL ch01 TYPE DISK FORMAT '/u03/backup/rman/%d_%s_%p_%T_%U.bck';
ALLOCATE CHANNEL ch02 TYPE DISK FORMAT '/u03/backup/rman/%d_%s_%p_%T_%U.bck';
ALLOCATE CHANNEL ch03 TYPE DISK FORMAT '/u03/backup/rman/%d_%s_%p_%T_%U.bck';
backup as compressed backupset full database include current controlfile;
backup as compressed backupset archivelog all;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}
BACKUP ARCHIVELOGS
connect target rman/@letodb;
run {
ALLOCATE CHANNEL ch00 TYPE DISK FORMAT '/u03/backup/rman/%d_%e_%h_%s_%p_%T_%U.bck';
ALLOCATE CHANNEL ch01 TYPE DISK FORMAT '/u03/backup/rman/%d_%e_%h_%s_%p_%T_%U.bck';
ALLOCATE CHANNEL ch02 TYPE DISK FORMAT '/u03/backup/rman/%d_%e_%h_%s_%p_%T_%U.bck';
ALLOCATE CHANNEL ch03 TYPE DISK FORMAT '/u03/backup/rman/%d_%e_%h_%s_%p_%T_%U.bck';
backup as compressed backupset archivelog all;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}
run
{
allocate channel c1 type disk format '/oracle/backup/rman_db_%T_%U.rman';
backup as compressed backupset full database include current controlfile;
release channel c1;
allocate channel c1 type disk
format '/oracle/backup/rman_arc_%T_%U.rman';
sql "alter system archive log current";
delete noprompt archivelog all backed up 2 times to device type disk;
backup as compressed backupset archivelog all;
sql "alter database backup controlfile
to ''/oracle/backup/rman_control.rman'' reuse";
release channel c1;
}
----------------- backup.rcv for RAC -----------------
run
{
allocate channel c1 type disk format '/oracle/backup/rman_db_%T_%U.rman';
connect 'sys/sys@node1';
backup as compressed backupset full database include current controlfile;
release channel c1;
allocate channel c1 type disk format '/oracle/backup/rman_arc_%T_%U.rman';
connect 'sys/sys@node1';
allocate channel c2 type disk format '/oracle/backup/rman_arc_%T_%U.rman';
connect 'sys/sys@node2';
sql "alter system archive log current";
delete noprompt archivelog all backed up 2 times to device type disk;
backup as compressed backupset archivelog all;
sql "alter database backup controlfile
to ''/oracle/backup/rman_control.rman'' reuse";
release channel c1;
release channel c2;
}
----------------- end of backup.rcv -----------------
Now, to use this script just execute:
rman target / cmdfile=backup.rcv
OTROS SCRIPTS BACKUP
export PATH
ORACLE_SID=
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
PATH=$ORACLE_HOME/OPatch:$ORACLE_HOME/bin/:$PATH:/sbin
export ORACLE_SID
export ORACLE_BASE
export ORACLE_HOME
export PATH
export NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS'
fecha=`date +'%m%d%y'`
LOGDIR=/u03/backups/rman/logs
rman target / catalog rmancat/@rmancat log=$LOGDIR/log_rman_full_fonpetp_$fecha.log <
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
BACKUP as compressed backupset DATABASE FORMAT '/u03/backups/rman/full_%d_%U_%T.bak';
BACKUP ARCHIVELOG ALL FORMAT '/u03/backups/rman/archivelog_%d_%U_%T.bak';
BACKUP CURRENT CONTROLFILE FORMAT '/u03/backups/rman/controlfile_%d_%U_%T.bak';
}
DELETE NOPROMPT ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE DISK;
allocate channel for maintenance type disk;
delete noprompt obsolete device type disk;
release channel;
EOF
PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
PATH=$PATH:$HOME/bin
export PATH
ORACLE_SID=
ORACLE_UNQNAME=
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
fecha=`date +'%m%d%y'`
PATH=$ORACLE_HOME/OPatch:$ORACLE_HOME/bin/:$PATH:/sbin
export ORACLE_UNQNAME
export ORACLE_SID
export ORACLE_BASE
export ORACLE_HOME
export PATH
$ORACLE_HOME/bin/expdp backups/ full=y directory=backup_expdp dumpfile=full_$fecha.dmp logfile=full_$fecha.log
cd /u03/backups/export/
#tar cvfz full_$fecha.tar.gz full_$fecha.log full_$fecha.dmp
gzip full_$fecha.log full_$fecha.dmp
VERIFICAR EL ESTADO DE LOS BACKUPS
select object_type, status START_TIME from v$rman_status where object_type IN ('DB FULL','ARCHIVELOG');
/u03/backups/export/fonpetp/expdp_full_fonpetp.sh
PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
PATH=$PATH:$HOME/bin
export PATH
ORACLE_SID=fonpetp
ORACLE_UNQNAME=fonpetp
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
fecha=`date +'%m%d%y'`
PATH=$ORACLE_HOME/OPatch:$ORACLE_HOME/bin/:$PATH:/sbin
export ORACLE_UNQNAME
export ORACLE_SID
export ORACLE_BASE
export ORACLE_HOME
export PATH
$ORACLE_HOME/bin/expdp
backups/ full=y directory=backup_expdp
dumpfile=full_fonpetp_$fecha.dmp logfile=full_fonpetp_$fecha.log
cd /u03/backups/export/fonpetp
#tar cvfz
full_fonpetp_$fecha.tar.gz
full_fonpetp_$fecha.log full_fonpetp_$fecha.dmp
gzip
full_fonpetp_$fecha.log full_fonpetp_$fecha.dmp
/u03/backups/export/depura_backup_exp.sh
find
/u03/backups/export/fonpetp/full_fonpetp*.dmp
-mtime +1 -exec rm {} \;
find
/u03/backups/export/fonpetp/full_fonpetp*.log
-mtime +1 -exec rm {} \;
find
/u03/backups/export/fonpetp/full_fonpetp*.gz
-mtime +3 -exec rm {} \;
/root/backupdia
##################################################################
#Script de copia de backups
diarios a cinta y disco externo
##################################################################
FECHABACKUP=`date
"+%Y%m%d%H"`
#Copia a cinta
echo "Inicia copia a
cinta" >>/tmp/backups/LOG_$FECHABACKUP.LOG
FECHA=`date
"+%Y%m%d%H%M"`
echo $FECHA
>>/tmp/backups/LOG_$FECHABACKUP.LOG
tar cvf /dev/st0
/u03/backups/
echo "Finaliza copia a
cinta" >>/tmp/backups/LOG_$FECHABACKUP.LOG
FECHA=`date
"+%Y%m%d%H%M"`
echo $FECHA
>>/tmp/backups/LOG_$FECHABACKUP.LOG
##Genera catágo de la
copia
tar tvf /dev/st0 >
/tmp/backups/LOG_CINTA_$FECHABACKUP.LOG
#expulsa la cinta
mt -f /dev/st0 eject
##copia al disco externo
echo "Inicia copia a
disco" >>/tmp/backups/LOG_$FECHABACKUP.LOG
FECHA=`date
"+%Y%m%d%H%M"`
echo $FECHA
>>/tmp/backups/LOG_$FECHABACKUP.LOG
cp -a /u03/backups /mnt/
echo "Finaliza copia a
disco" >>/tmp/backups/LOG_$FECHABACKUP.LOG
FECHA=`date
"+%Y%m%d%H%M"`
echo $FECHA
>>/tmp/backups/LOG_$FECHABACKUP.LOG
CRONTAB
10 21 * * * /u03/backups/rman/fonpetp/scripts/rman_full_fonpetp.sh
Descripción: todos los días a las 21:10 se ejecuta el script rman_full_fonpetp.sh
00 21 * * * /u03/backups/rman/asdbp/scripts/rman_full_asdbp.sh
Descripción: todos los días a las 21:00 se ejecuta el script rman_full_asdbp.sh
00 22 * * * /u03/backups/export/asdbp/expdp_full_asdbp.sh
Descripción: todos los días a las 22:00 se ejecuta el script expdp_full_asdbp.sh
5 5 * * * /u03/backups/export/depura_backup_exp.sh
Descripción: todos los días a las 05:05 se ejecuta el script depura_backup_exp.sh
No hay comentarios:
Publicar un comentario