Skip to content
Advertisements

Archive for

Simple cronjob for datapump

Today morning I just written a small script for taking full database using datapump and after I scheduled on every one week with cron.

#!/bin/bash
#Script to perform a full database  export backup using by datapump on every wednesday
# Script Written by
# Mohamed Azar http://mohamedazar.com
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH; export PATH
ORACLE_SID=devcrm; export ORACLE_SID
expdp system/Admin123 directory=exportdb dumpfile=exportdb-$(date +%Y-%m-%d).dmp logfile=exportdb-$(date +%Y-%m-%d).log full=y exclude=statistics
# Send log to mail
tail -4 /u01/datapump/dumps/exportdb-$(date +%Y-%m-%d).log | mailx -s “Cronjob Oracle Export Output:SIEBELDEV” mazar@ace-ins.com

#Remove old previous dumpfile
rm -rf /u01/datapump/dumps/previous/*.*

#Find out last week dumpfiles and move to previous directory
cd /u01/datapump/dumps
chown -Rf oracle:oinstall *.dmp *.log
chmod -Rf 775 *.dmp *.log
find -mtime +6 -exec mv {} /u01/datapump/dumps/previous \;
gzip /u01/datapump/previous/*.*
gzip *.dmp *.log

Cronjob schedule :

I scheduled here , every week on wednesday at 04:00pm

[oracle@siebelpoc cronjob]$ vi cron.exportdb
0 16 * * 3 /u01/datapump/dumps/scripts/exportdb.sh

[oracle@siebelpoc cronjob]$crontab cron.exportdb

Advertisements