From 7ac04d3301d4fca0fdca6f8693f9f07f7714ba00 Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Wed, 17 Jul 2024 12:57:42 -0400 Subject: [PATCH 1/2] Include docker-compose steps in hosting for localized database backups --- tools/hosting/docker-compose.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/hosting/docker-compose.yml b/tools/hosting/docker-compose.yml index f60b1c09b55..9741d8e1797 100644 --- a/tools/hosting/docker-compose.yml +++ b/tools/hosting/docker-compose.yml @@ -29,6 +29,8 @@ services: - VIRTUAL_HOST=${PUBLIC_HOST} - LETSENCRYPT_HOST=${PUBLIC_HOST} user: ${USER_UID:-1000}:${USER_GID:-1000} + networks: + - webknossos_default # Postgres postgres: @@ -59,6 +61,7 @@ services: # FossilDB fossildb: image: scalableminds/fossildb:master__489 + container_name: webknossos-fossildb-1 command: - fossildb - -c @@ -97,6 +100,7 @@ services: labels: - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy + # Nginx-Lets-Encrypt nginx-letsencrypt: image: nginxproxy/acme-companion environment: @@ -108,3 +112,30 @@ services: - ./persistent/nginx/certs:/etc/nginx/certs - ./persistent/nginx/vhost.d:/etc/nginx/vhost.d - ./persistent/nginx/html:/usr/share/nginx/html + + # FossilDB Backup -- backup located to ../persistent/fossildb/backup/private after completion + # Example command: docker-compose run --rm fossil-db-backup + fossil-db-backup: + image: scalableminds/fossildb-client:master + depends_on: + fossildb: + condition: service_healthy + command: ["webknossos-fossildb-1", "backup"] + networks: + - webknossos_default + + # FossilDB Restore + # Example command: docker-compose run --rm fossil-db-restore + fossil-db-restore: + image: scalableminds/fossildb-client:master + depends_on: + fossildb: + condition: service_healthy + command: [ "webknossos-fossildb-1", "restore" ] + networks: + - webknossos_default + +# Explicitly declare networks for fossil-db-backup connectivity +networks: + webknossos_default: + external: true From 1a427dd7c17ba0fa009ebcf7969a80f674117841 Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Fri, 19 Jul 2024 13:48:45 -0400 Subject: [PATCH 2/2] include postgres-backup step --- tools/hosting/docker-compose.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/hosting/docker-compose.yml b/tools/hosting/docker-compose.yml index 9741d8e1797..9f84acdc691 100644 --- a/tools/hosting/docker-compose.yml +++ b/tools/hosting/docker-compose.yml @@ -135,6 +135,15 @@ services: networks: - webknossos_default + # Postgres backup + postgres-backup: + image: postgres + command: [ "/bin/bash", "-c", "PGPASSWORD=postgres pg_dump -Fc -h postgres -U postgres webknossos | gzip > /backups/backup_$(date +%Y-%m-%d_%H-%M).sql.gz" ] + volumes: + - ./backups:/backups + depends_on: + - postgres + # Explicitly declare networks for fossil-db-backup connectivity networks: webknossos_default: