From 096c70907efc63bc9e39d838cb18a5ac3312d9ae Mon Sep 17 00:00:00 2001 From: Sebastian Wollner Date: Tue, 10 Sep 2024 10:10:22 +0200 Subject: [PATCH] fix: missing mongodb backup for compose --- .../docker/compose/src/main/scripts/utils.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/archetypes/project/src/main/resources/archetype-resources/deploy/docker/compose/src/main/scripts/utils.sh b/archetypes/project/src/main/resources/archetype-resources/deploy/docker/compose/src/main/scripts/utils.sh index a74ce6de..420ea4da 100755 --- a/archetypes/project/src/main/resources/archetype-resources/deploy/docker/compose/src/main/scripts/utils.sh +++ b/archetypes/project/src/main/resources/archetype-resources/deploy/docker/compose/src/main/scripts/utils.sh @@ -335,8 +335,25 @@ backup() { if [[ -n $repodb ]] ; then - echo "backup postgres" + if [[ "$($COMPOSE_EXEC ps repository-mongo -a)" != "no such service: repository-mongo" ]]; then + echo "backup mongo" + if [[ -n $compressed ]] ; then + $COMPOSE_EXEC exec -t repository-mongo sh -c "mongodump --archive --gzip -u ${REPOSITORY_MONGO_ROOT_USER:-root} -p ${REPOSITORY_MONGO_ROOT_PASS:-root}" >"$backupDir/repository-mongo.gz" || { + rm -rf "$backupDir" + echo "ERROR on creating mongodb dump" + exit 1 + } + else + $COMPOSE_EXEC exec -t repository-mongo sh -c "mongodump --archive -u ${REPOSITORY_MONGO_ROOT_USER:-root} -p ${REPOSITORY_MONGO_ROOT_PASS:-root}" >"$backupDir/repository-mongo.dump" || { + rm -rf "$backupDir" + echo "ERROR on creating mongodb dump" + exit 1 + } + fi + fi + + echo "backup postgres" if [[ -n $compressed ]] ; then $COMPOSE_EXEC exec -t repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; pg_dump --username ${REPOSITORY_DATABASE_USER:-repository} --format custom --no-owner --no-privileges ${REPOSITORY_DATABASE_NAME:-repository} | gzip" >"$backupDir/repository-db.gz" || { rm -rf "$backupDir"