From e3ee53b52560d88f128b1db012f9cb4830b4d883 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 18 Jan 2021 14:47:39 +0100 Subject: [PATCH] use relative symlinks --- dev/local/restore_db.sh | 3 ++- prod/local/backup_db.sh | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dev/local/restore_db.sh b/dev/local/restore_db.sh index 04a2013..1360fa6 100755 --- a/dev/local/restore_db.sh +++ b/dev/local/restore_db.sh @@ -12,7 +12,8 @@ if [ -f /srv/backup/postgres.dump ]; then echo 'A backup without date was found. Moving it to postgres_old.dump' mv /srv/backup/postgres.dump /srv/backup/postgres_old.dump if [ ! -f /srv/backup/postgres_latest.dump ]; then - ln -s /srv/backup/postgres_old.dump /srv/backup/postgres_latest.dump + cd /srv/backup + ln -s postgres_old.dump postgres_latest.dump fi fi diff --git a/prod/local/backup_db.sh b/prod/local/backup_db.sh index 174790b..c6727de 100755 --- a/prod/local/backup_db.sh +++ b/prod/local/backup_db.sh @@ -12,7 +12,8 @@ if [ -f /srv/backup/postgres.dump ]; then echo 'A backup without date was found. Moving it to postgres_old.dump' mv /srv/backup/postgres.dump /srv/backup/postgres_old.dump if [ ! -f /srv/backup/postgres_latest.dump ]; then - ln -s /srv/backup/postgres_old.dump /srv/backup/postgres_latest.dump + cd /srv/backup + ln -s postgres_old.dump postgres_latest.dump fi fi @@ -23,8 +24,9 @@ elif [ ! -z "$POSTGRES_PASSWORD" ]; then export PGPASSWORD=$POSTGRES_PASSWORD now=$(date +"%m_%d_%Y_%H_%M_%S") pg_dump -Fc -hdb -Upostgres -dpostgres > /srv/backup/postgres_$now.dump - rm -f /srv/backup/postgres_latest.dump - ln -s /srv/backup/postgres_$now.dump /srv/backup/postgres_latest.dump + cd /srv/backup + rm -f postgres_latest.dump + ln -s postgres_$now.dump postgres_latest.dump fi echo "Backup done!" -- 2.39.5