From 2561b40558026aadf94a919649ca7d9db1c0d2c9 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 28 Jun 2021 14:00:23 +0200 Subject: [PATCH] use env variables only (WARNING: check PRODUCTION env variables) --- dev/local/restore_db.sh | 8 ++++---- prod/local/backup_db.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/local/restore_db.sh b/dev/local/restore_db.sh index 711da15..21889ef 100755 --- a/dev/local/restore_db.sh +++ b/dev/local/restore_db.sh @@ -13,13 +13,13 @@ if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then elif [ ! -z "$POSTGRES_PASSWORD" ]; then export PGPASSWORD=$POSTGRES_PASSWORD echo "Killing clients..." - psql -hdb -Upostgres -dpostgres -c "SELECT pid, (SELECT pg_terminate_backend(pid)) as killed from pg_stat_activity WHERE state LIKE 'idle';" + psql -h$POSTGRES_HOST -U$POSTGRES_USER -d$POSTGRES_DB -c "SELECT pid, (SELECT pg_terminate_backend(pid)) as killed from pg_stat_activity WHERE state LIKE 'idle';" echo "Dropping db..." - dropdb -hdb -Upostgres postgres + dropdb -h$POSTGRES_HOST -U$POSTGRES_USER $POSTGRES_DB echo "Creating new db..." - createdb -hdb -Upostgres -T template0 postgres + createdb -h$POSTGRES_HOST -U$POSTGRES_USER -T template0 $POSTGRES_DB echo "Importing dump..." - pg_restore -C -c -hdb -Upostgres -dpostgres /srv/backup/postgres.dump + pg_restore -C -c -h$POSTGRES_HOST -U$POSTGRES_USER -d$POSTGRES_DB /srv/backup/postgres.dump fi echo "Restore done!" diff --git a/prod/local/backup_db.sh b/prod/local/backup_db.sh index 07c38c3..0ea80c0 100755 --- a/prod/local/backup_db.sh +++ b/prod/local/backup_db.sh @@ -12,7 +12,7 @@ if [ ! -z "$MYSQL_PASSWORD" ]; then mysqldump $MYSQL_DATABASE -hdb -u$MYSQL_USER | gzip > /srv/backup/mysql.dump.gz elif [ ! -z "$POSTGRES_PASSWORD" ]; then export PGPASSWORD=$POSTGRES_PASSWORD - pg_dump -Fc -hdb -Upostgres -dpostgres > /srv/backup/postgres.dump + pg_dump -Fc -h$POSTGRES_HOST -U$POSTGRES_USER -d$POSTGRES_DB > /srv/backup/postgres.dump fi echo "Backup done!" -- 2.39.5