]> git.parisson.com Git - docker-django-scripts.git/commitdiff
feat(backup/restore): add echo and do not override symbolic link
authorMartin Desrumaux <martin@letik.io>
Tue, 5 Jan 2021 16:00:21 +0000 (17:00 +0100)
committerMartin Desrumaux <martin@letik.io>
Tue, 5 Jan 2021 16:00:21 +0000 (17:00 +0100)
dev/local/restore_db.sh
prod/local/backup_db.sh

index 4dcf40ca820c55e3f15e1d19311808c781caae4f..a412240a075828d87bf359aa00eb010235251261 100755 (executable)
@@ -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
index f1778d3a13c64111618c910a5758add58da5f77e..70ac0373f32b5f27c7a0a479539fe609af1d14eb 100755 (executable)
@@ -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