|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cd /opt/oracle/backup/scripts || echo "failed to cd to /opt/oracle/backup/scripts" || exit 1 |
|
|
|
|
|
dateString=$(date +%Y_%m_%d_%H_%M_%S) |
|
|
logfile=orclpdb1_${dateString}.log |
|
|
dumpfile=orclpdb1_${dateString}.dmp |
|
|
|
|
|
password=$(cat /opt/oracle/backup/scripts/password.txt) |
|
|
|
|
|
|
|
|
SCN=$(sqlplus -S -L "system/${password}@ORCLPDB1" @newscn.sql | xargs) || echo "error getting scn" || exit 1 |
|
|
echo SCN is "'${SCN}'" |
|
|
|
|
|
|
|
|
expdp \ |
|
|
"system/${password}@localhost:1521/ORCLPDB1" \ |
|
|
directory=EXT_DATA_PUMP_DIR \ |
|
|
dumpfile="${dumpfile}" \ |
|
|
logfile="${logfile}" \ |
|
|
schemas=vcell \ |
|
|
flashback_scn="${SCN}" |
|
|
|
|
|
expdp_returnCode=$? |
|
|
if [ $expdp_returnCode != 0 ]; then |
|
|
echo "Error exporting database" |
|
|
exit 1 |
|
|
else |
|
|
echo "database dump to ${dumpfile} complete, please check logs in ${logfile}" |
|
|
exit 0 |
|
|
fi |
|
|
|