From fc1105f04ed74c36e4a54d98f4e4a563d6b5a75d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9s=20Maldonado?= <amaldona@etu.utc.fr>
Date: Tue, 28 Apr 2020 02:00:45 +0200
Subject: [PATCH] [pica-db-backup][run.sh] Exit on failure of "children"
 scripts

This should kill the container if there were errors on one of the
"children" scripts, making it more obvious that there was a problem.
---
 pica-db-backup/run.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pica-db-backup/run.sh b/pica-db-backup/run.sh
index f89bf69d..12486ddc 100755
--- a/pica-db-backup/run.sh
+++ b/pica-db-backup/run.sh
@@ -84,6 +84,7 @@ for (( i=0; i < $NB_CALLS; i++ )); do
   EXTRA_OPTS=${MYSQL_EXTRA_OPTS_ARRAY[i]} \
   BACKUP_FOLDER="/backup/${MYSQL_BACKUP_FOLDER_ARRAY[i]}/" \
   /scripts/mysql/mysql-run.sh
+  [ $? == 1 ] && exit 1
 done
 
 #Execute PostgreSQL backups
@@ -101,6 +102,7 @@ for (( i=0; i < $NB_CALLS; i++ )); do
   EXTRA_OPTS=${POSTGRES_EXTRA_OPTS_ARRAY[i]} \
   BACKUP_FOLDER="/backup/${POSTGRES_BACKUP_FOLDER_ARRAY[i]}/" \
   /scripts/postgresql/postgres-run.sh
+  [ $? == 1 ] && exit 1
 done
 
 #Execute MongoDB backups
@@ -117,6 +119,7 @@ for (( i=0; i < $NB_CALLS; i++ )); do
   CRON_TIME=${MONGO_CRON_TIME_ARRAY[i]} \
   BACKUP_FOLDER="/backup/${MONGO_BACKUP_FOLDER_ARRAY[i]}/" \
   /scripts/mongodb/mongo-run.sh
+  [ $? == 1 ] && exit 1
 done
 
 exec cron -f
-- 
GitLab