find /Oracle/Cron_exp_backup/ntucusr* -mtime +1 -exec rm {} \;
to take a full backup through RMAN: -
rman target sys/orcl@orcl catalog rman/rman@orcl cmdfile=/home/oracle/rman.sql
rman.sql: -
backup database;
How to generate unique logfile through crontab:
30 12 * * * /u01/app/oracle/bin/rman_backup.pl > /u01/app/oracle/log/rman_backup_$(date +\%Y\%m\%d_\%H:\%M:\%S\%z).log > /dev/null 2>&1
If you need only the date (not including the time element):
30 12 * * * /u01/app/oracle/bin/rman_backup.pl > /u01/app/oracle/log/rman_backup_$(date +\%Y\%m\%d).log > /dev/null 2>&1
#Backup script by Cédric Sougné.
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=(sid_name)
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
ADMIN_EMAIL= »
LOGFILE=$ORACLE_BASE/admin/$ORACLE_SID/backup_logs/expdp-`date +%d%m%y%H%M%S`.log
EXPORT_PATH=/u01/oracle/export_backup
DMP_FILE= »expdp-`date + »%d%m%Y_%H%M%S »`.dmp »
LOG_FILE= »expdp-`date + »%d%m%Y_%H%M%S »`.log »
echo « Starting … » > $LOGFILE
expdp \’sys/
#expdp mrmrs/mrmrs TABLES=resident,sejour DIRECTORY=EXPORT_BACKUP_DIR DUMPFILE=$DMP_FILE LOGFILE=$LOG_FILE
cat $EXPORT_PATH/$LOG_FILE >> $LOGFILE
echo « Backup Completed. » >> $LOGFILE
echo « gzipping … » >> $LOGFILE
gzip $EXPORT_PATH/$DMP_FILE >> $LOGFILE
echo « gzipping Completed. » >> $LOGFILE
echo « Deleting old files » >> $LOGFILE
find $EXPORT_PATH -type f -mtime +31 | xargs rm >> $LOGFILE
echo « Delete Completed » >> $LOGFILE
cat $LOGFILE | mail -s « expdp-`date + »%d%m%Y_%T »` » $ADMIN_EMAIL
Here is for the cron tab:
30 23 * * * /opt/oracle/admin/acisora1/scripts/export_backup.sh >> /dev/null
the script will be executed avery at 11:30 pm
________________________________________________________________________
Oracle Export and Import Compress Scripts: -
Export Script: -
#!/bin/ksh
# Export with flags (full, consistent) to a compressed file that
# is named by SID-month-day using Oracle exp
##############################################
# Main
# Configure environment
. oracle_environment.ksh # Oracle environment.
export ORACLE_SID=XXX1
DIRECTORY=/apps/home/oracle/local; export DIRECTORY
FILENAME=${DIRECTORY}/Exports/${ORACLE_SID}-`date +%d`.dmp.gz; export FILENAME
LOG=${DIRECTORY}/Exports/${ORACLE_SID}-`date +%d`.log; export LOG
PIPE=${DIRECTORY}/export_pipe.dmp; export PIPE
test -p ${PIPE} || mknod ${PIPE} p
chmod +rw ${PIPE}
cat $PIPE | /usr/local/bin/gzip > ${FILENAME} &
${ORACLE_HOME}/bin/exp log=${LOG} buffer=10485760 file=${PIPE} consistent=yes fu
ll=yes << EOF
system/password
EOF
#############################################################
Import Script: -
#!/bin/ksh
# Oracle imp import for gzipped Oracle exp file.
##############################################
# Main
# Path of exp file.
FILENAME=$1; export FILENAME
PIPE=export_pipe.dmp; export PIPE
test -p ${PIPE} || mknod export_pipe.dmp p
chmod +rw ${PIPE}
/usr/local/bin/zcat ${FILENAME} > ${PIPE} &
${ORACLE_HOME}/bin/imp buffer=10485760 file=${PIPE} full=yes log=impzip.log << EOF
system/password
EOF
#########################################################