parent
f570084f50
commit
1ae64462a5
@ -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