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
Hi I tried the above cronjob but getting the below exception.
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31641: unable to create dump file “/opt/oracle/admin/CI/dpdumps/export_full.dmp”
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Could you please help me to solve this???
Thanks Mohamed!
How to add to this script gzip or bzip2 compression?
What ?