This commit is contained in:
parent
197feb32f3
commit
9124dab6ab
2
abra.sh
2
abra.sh
@ -17,7 +17,7 @@ export RALLLY_CONFIG_VERSION=v2
|
|||||||
export HEDGEDOC_CONFIG_VERSION=v1
|
export HEDGEDOC_CONFIG_VERSION=v1
|
||||||
export MONITORING_CONFIG_VERSION=v2
|
export MONITORING_CONFIG_VERSION=v2
|
||||||
export DB_ENTRYPOINT_VERSION=v1
|
export DB_ENTRYPOINT_VERSION=v1
|
||||||
export PG_BACKUP_VERSION=v1
|
export PG_BACKUP_VERSION=v2
|
||||||
|
|
||||||
customize() {
|
customize() {
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
|
13
pg_backup.sh
13
pg_backup.sh
@ -11,17 +11,24 @@ function backup {
|
|||||||
|
|
||||||
function restore {
|
function restore {
|
||||||
cd /var/lib/postgresql/data/
|
cd /var/lib/postgresql/data/
|
||||||
|
restore_config(){
|
||||||
|
# Restore allowed connections
|
||||||
|
cat pg_hba.conf.bak > pg_hba.conf
|
||||||
|
su postgres -c 'pg_ctl reload'
|
||||||
|
}
|
||||||
# Don't allow any other connections than local
|
# Don't allow any other connections than local
|
||||||
cp pg_hba.conf pg_hba.conf.bak
|
cp pg_hba.conf pg_hba.conf.bak
|
||||||
echo "local all all trust" > pg_hba.conf
|
echo "local all all trust" > pg_hba.conf
|
||||||
su postgres -c 'pg_ctl reload'
|
su postgres -c 'pg_ctl reload'
|
||||||
|
trap restore_config EXIT INT TERM
|
||||||
|
|
||||||
# Recreate Database
|
# Recreate Database
|
||||||
psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);"
|
psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);"
|
||||||
createdb -U ${POSTGRES_USER} ${POSTGRES_DB}
|
createdb -U ${POSTGRES_USER} ${POSTGRES_DB}
|
||||||
psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f $BACKUP_FILE
|
psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f $BACKUP_FILE
|
||||||
# Restore allowed connections
|
|
||||||
cat pg_hba.conf.bak > pg_hba.conf
|
trap - EXIT INT TERM
|
||||||
su postgres -c 'pg_ctl reload'
|
restore_config
|
||||||
}
|
}
|
||||||
|
|
||||||
$@
|
$@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user