24 lines
463 B
Bash
24 lines
463 B
Bash
|
#/bin/bash
|
||
|
set -e
|
||
|
|
||
|
app=keycloak # service and (optional) dumpfile name
|
||
|
db=db123_user
|
||
|
user=$db
|
||
|
dump=$HOME/var/db/$app.dump
|
||
|
|
||
|
# ensure systemctl --user works
|
||
|
export XDG_RUNTIME_DIR=/run/user/$UID
|
||
|
|
||
|
echo "stopping $app..."
|
||
|
systemctl stop --user $app
|
||
|
|
||
|
echo "restoring database..."
|
||
|
# -c drops all objects that are to be restored
|
||
|
pg_restore -c -h localhost -U $user -d $db < $dump
|
||
|
|
||
|
systemctl start --user $app
|
||
|
|
||
|
echo "started $app..."
|
||
|
sleep 2
|
||
|
|
||
|
systemctl status --user $app
|