Script for restore DB
This commit is contained in:
parent
f570084f50
commit
1ae64462a5
|
@ -1,4 +1,9 @@
|
|||
|
||||
0.4.0 [28-Ene-2021]
|
||||
---------------------
|
||||
- Script para restaurar DB.
|
||||
|
||||
|
||||
0.3.0 [28-Ene-2021]
|
||||
---------------------
|
||||
- Script para iniciar VPN de soporte.
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
WHITE='\033[1;37m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "\033[33;5;7m¡CUIDADO! ESTE ES UN PROCESO DESTRUCTIVO\033[0m"
|
||||
echo ''
|
||||
echo "CONTINUA SOLO SI ESTAS 100% SEGURO"
|
||||
echo ''
|
||||
sleep 1
|
||||
|
||||
read -p "¿Estas seguro de restaurar esta base de datos? (escribe Si para confirmar)"
|
||||
if [ "$REPLY" != "Si" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo ''
|
||||
rfc="${1:0:-3}"
|
||||
rfc="${rfc,,}"
|
||||
name="$1"
|
||||
path="$HOME/compartido/$name"
|
||||
|
||||
if ! [ -f $path ]; then
|
||||
echo "No se encontró la base de datos: $name"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "Restaurando base de datos: $name"
|
||||
psql -U postgres -c "DROP DATABASE $rfc"
|
||||
psql -U postgres -c "CREATE DATABASE $rfc WITH OWNER $rfc"
|
||||
pg_restore -U postgres -d $rfc $path
|
||||
echo "Base de datos restaurada correctamente"
|
Loading…
Reference in New Issue