diff --git a/Makefile b/Makefile index 0ef9419..e0e2e8b 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ PRE_COMMIT_VERSION ?= 4.3.0 # Env file is always instances/$(PROJECT_NAME).env — generated by scripts/generate-env.sh. PROJECT_NAME ?= $(notdir $(CURDIR)) ENV_FILE = instances/$(PROJECT_NAME).env +BACKUP_DIR ?= ./backups/$(PROJECT_NAME) .PHONY: init playwright test reinit check backup-database backup-file-storage backup restore-database restore-file-storage restore docs generate-stack-envs create-instance launch-postgres launch-instance launch-traefik launch-monitoring ensure-networks stop-instance clean clean-all config get-backup-timestamp @@ -48,7 +49,7 @@ POSTGRES_COMPOSE_CMD = docker compose \ --env-file $(ENV_FILE) \ -f stacks/postgres/docker-compose.yml -BACKUP_COMPOSE_CMD = docker compose \ +BACKUP_COMPOSE_CMD = BACKUP_DIR=$(BACKUP_DIR) docker compose \ --project-name $(PROJECT_NAME) \ --env-file $(ENV_FILE) \ -f docker-compose.yml \ @@ -58,11 +59,11 @@ get-backup-timestamp: @echo $(BACKUP_TIMESTAMP) backup-database: - mkdir -p ./backups + mkdir -p $(BACKUP_DIR) $(BACKUP_COMPOSE_CMD) run -e BACKUP_TIMESTAMP=$(BACKUP_TIMESTAMP) --rm backup-database backup-file-storage: - mkdir -p ./backups + mkdir -p $(BACKUP_DIR) $(BACKUP_COMPOSE_CMD) run -e BACKUP_TIMESTAMP=$(BACKUP_TIMESTAMP) --rm backup-file-storage backup: backup-database backup-file-storage diff --git a/stacks/backup/docker-compose.yml b/stacks/backup/docker-compose.yml index 5b222e4..3bc08c2 100644 --- a/stacks/backup/docker-compose.yml +++ b/stacks/backup/docker-compose.yml @@ -7,7 +7,7 @@ x-file-storage-image: &file-storage-image services: backup-database: volumes: - - ./backups:/backups + - ${BACKUP_DIR}:/backups - ./scripts/backup-database.sh:/backup-database.sh:ro environment: # -- Database hostname @@ -32,7 +32,7 @@ services: backup-file-storage: volumes: - dhis2:/opt/dhis2:ro - - ./backups:/backups + - ${BACKUP_DIR}:/backups - ./scripts/backup-file-storage.sh:/backup-file-storage.sh:ro environment: # -- Backup timestamp. Used to name the backup directory and the backup file. Since those are created by different containers, we need to ensure the backup timestamp is the same for both containers. @@ -48,7 +48,7 @@ services: restore-database: volumes: - - ./backups:/backups:ro + - ${BACKUP_DIR}:/backups:ro - ./scripts/restore-database.sh:/restore-database.sh:ro - ./scripts/fix-ownership.sh:/fix-ownership.sh:ro environment: @@ -76,7 +76,7 @@ services: restore-file-storage: volumes: - dhis2:/opt/dhis2 - - ./backups:/backups:ro + - ${BACKUP_DIR}:/backups:ro - ./scripts/restore-file-storage.sh:/restore-file-storage.sh:ro environment: # -- Directory to restore from