Created
June 23, 2022 21:00
-
-
Save klascano/e91eb67cb8640da6b886a9ca86c0c11a to your computer and use it in GitHub Desktop.
oracle backup from docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FECHA=`date +%Y%m%d%H%M` | |
rm -rf respaldo.log | |
docker exec oracle122c_prod /bin/bash -c "rm -rf /u02/app/oracle/oradata/sgd$FECHA.dmp" | |
docker exec oracle122c_prod /bin/bash -c "rm -rf /u02/app/oracle/oradata/sgd$FECHA.log" | |
echo "**********borrado de archivo respaldo anteriores**********" | |
echo " " | |
docker exec oracle122c_prod /bin/bash -c "ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1 ORACLE_SID=ORCLCDB /u01/app/oracle/product/12.2.0/dbhome_1/bin/expdp system/UZrC3Z schemas=seguridad directory=TEST_DIR dumpfile=sgd$FECHA.dmp logfile=sgd$FECHA.log" | |
echo "**********fin de respaldo**********" | |
echo " " | |
docker cp oracle122c_prod:/u02/app/oracle/oradata/sgd$FECHA.dmp /home/oracle/respaldos/sgd$FECHA.dmp | |
echo "**********copia respaldo a host**********" | |
echo " " | |
7za a /home/oracle/respaldos/sgd$FECHA.7z /home/oracle/respaldos/sgd$FECHA.dmp | |
rm -rf /home/oracle/respaldos/sgd$FECHA.dmp | |
fs=$(wc -c /home/oracle/respaldos/sgd$FECHA.7z | awk '{print $1}') | |
rfs=`expr $fs / 1024 / 1024` | |
echo "**********fin de compresion y borrado de temporal**********" | |
echo " " | |
docker exec oracle122c_prod /bin/bash -c "rm -rf /u02/app/oracle/oradata/sgd$FECHA.dmp" | |
docker exec oracle122c_prod /bin/bash -c "rm -rf /u02/app/oracle/oradata/sgd$FECHA.log" | |
echo "**********notificando a administrador**********" | |
echo " " | |
FECHAFIN=`date +%d\/%m\/%Y\ %H\:%M` | |
nf="/home/oracle/respaldos/sgd$FECHA.7z( $rfs Mb)" | |
echo $nf | |
mj_payload(){ | |
cat <<EOF | |
{ | |
"Messages":[ | |
{ | |
"From": { | |
"Email": "[email protected]", | |
"Name": "SGD Correo" | |
}, | |
"To": [ | |
{ | |
"Email": "[email protected]", | |
"Name": "jose" | |
},{ | |
"Email": "[email protected]", | |
"Name": "klever" | |
},{ | |
"Email": "[email protected]", | |
"Name": "alvaro" | |
} | |
], | |
"Subject": "Respaldo sgd generado $FECHA", | |
"TextPart": "Se ha generado un nuevo respaldo de sgd $nf el $FECHAFIN. Favor verificar periodicamente el espacio en disco y su traslado a una ubicacion diferente al servidor.", | |
"HTMLPart": "Se ha generado un nuevo respaldo de SGD <b>$nf</b> el $FECHAFIN.<br>Favor verificar periodicamente el espacio en disco y su traslado a una ubicacion diferente al servidor.<br>BESIXPLUS CIA. LTDA., no guarda informacion, datos o respaldos de sus clientes. El cliente es responsable de su informacion.", | |
"CustomID": "SgdRespaldo" | |
} | |
] | |
} | |
EOF | |
} | |
curl -s \ | |
-X POST \ | |
--user "78196e8a9ee96407b97509c8ba9afee5:3bbf1742781eaf34c34997d6bf728f9c" \ | |
https://api.mailjet.com/v3.1/send \ | |
-H 'Content-Type: application/json' \ | |
-d "$(mj_payload)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment