From 736c82bba96a86a34624fbd05252a8c5fa33b9d3 Mon Sep 17 00:00:00 2001 From: Martin Desrumaux Date: Tue, 5 Jan 2021 17:00:21 +0100 Subject: [PATCH] feat(backup/restore): add echo and do not override symbolic link --- dev/local/restore_db.sh | 5 ++++- prod/local/backup_db.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dev/local/restore_db.sh b/dev/local/restore_db.sh index 4dcf40c..a412240 100755 --- a/dev/local/restore_db.sh +++ b/dev/local/restore_db.sh @@ -9,8 +9,11 @@ echo "Restoring..." # Migrate backup to date-based format 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 - ln -s /srv/backup/postgres_old.dump /srv/backup/postgres_latest.dump + if [ ! -f /srv/backup/postgres_latest.dump ]; then + ln -s /srv/backup/postgres_old.dump /srv/backup/postgres_latest.dump + fi fi # import database functions of type diff --git a/prod/local/backup_db.sh b/prod/local/backup_db.sh index f1778d3..70ac037 100755 --- a/prod/local/backup_db.sh +++ b/prod/local/backup_db.sh @@ -9,8 +9,11 @@ set -e # Migrate backup to date-based format 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 - ln -s /srv/backup/postgres_old.dump /srv/backup/postgres_latest.dump + if [ ! -f /srv/backup/postgres_latest.dump ]; then + ln -s /srv/backup/postgres_old.dump /srv/backup/postgres_latest.dump + fi fi if [ ! -z "$MYSQL_PASSWORD" ]; then -- 2.39.5