Oracle APEX application and workspace backup script

export APEX_UTIL_HOME=/u01/scripts/APEX/utilities
 * 1) The export files will be automatically placed at the location of the APEX utility scripts
 * 2) Use the scripts from the APEX download with same version of the APEX installation. If not, some java run errors may be experienced.
 * 1) Use the scripts from the APEX download with same version of the APEX installation. If not, some java run errors may be experienced.

export ORACLE_HOME=/u01/oracle/product/11.2.0/db_1 export CLASSPATH=.:${ORACLE_HOME}/jdbc/lib/ojdbc5.jar
 * 1) Export the CLASSPATH
 * 1) export CLASSPATH=.:${ORACLE_HOME}/jdbc/lib/ojdbc6.jar

export BACKUP_LOC=/u01/${ORACLE_SID}/APEX/backups export CURRDATE=`date '+%Y%m%d%H%M'`
 * 1) Setup environment variables

echo =========================================== | tee -a ${LOGFILE} echo Start APEX applications export at `date` | tee -a ${LOGFILE}

DBHOST="host:port:SID" DBHOST="(description=(address=(host=dbhost)(protocol=tcp)(port=1521))(connect_data=(service_name=DBSRV)))" USR="APEX_040200" PASSW="PWD"

cd ${APEX_UTIL_HOME} java oracle.apex.APEXExport -db ${DBHOST} -user ${USR} -password ${PASSW} -instance 2>&1 | tee -a ${LOGFILE} java oracle/apex/APEXExport -db ${DBHOST} -user ${USR} -password ${PASSW} -expWorkspace 2>&1 | tee -a ${LOGFILE}
 * 1) Perform exports

echo Compressing all .sql files to ${BACKUP_LOC}/${CURRDATE}.tar.gz cd ${APEX_UTIL_HOME} tar cvf - ./*.sql | gzip -c > ${BACKUP_LOC}/${CURRDATE}.tar.gz
 * 1) Archive and zip all fxxx.sql files generated from the APEX export.

rm -rf ${APEX_UTIL_HOME}/*.sql
 * 1) Remove all fxxx.sql files

echo End APEX applications export at `date` | tee -a ${LOGFILE}