From 6bf1a1089a15c340d19490142dbd019ca630532d Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Tue, 22 Sep 2020 00:45:45 +0200 Subject: [PATCH] Split backup into separate compose file --- .envrc.sample | 3 +++ README.md | 6 ++++++ compose.backup.yml | 47 ++++++++++++++++++++++++++++++++++++++++++++++ compose.yml | 39 -------------------------------------- 4 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 compose.backup.yml diff --git a/.envrc.sample b/.envrc.sample index 83df045..dac0ff9 100644 --- a/.envrc.sample +++ b/.envrc.sample @@ -23,3 +23,6 @@ export DB_PASSWORD_VERSION=v1 # define('BLOG_ID_CURRENT_SITE', 1);\ # define('FORCE_SSL_ADMIN', true );\ # define('COOKIE_DOMAIN', \$_SERVER['HTTP_HOST']);" + +# Backups +#export COMPOSE_FILE="compose.yml:compose.backup.yml" diff --git a/README.md b/README.md index a533444..c0e81fd 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,9 @@ _(Only tested using subdomains)_ [abra]: https://git.autonomic.zone/autonomic-cooperative/abra [compose-traefik]: https://git.autonomic.zone/compose-stacks/traefik + +## Backups + +1. Edit `.envrc` and uncomment the `export COMPOSE_FILE="compose.yml:compose.backup.yml"` line +2. `direnv allow` +3. `abra deploy` diff --git a/compose.backup.yml b/compose.backup.yml new file mode 100644 index 0000000..7618f60 --- /dev/null +++ b/compose.backup.yml @@ -0,0 +1,47 @@ +--- +version: "3.8" + +services: + backupbot: + image: "decentral1se/backup-bot:0.0.1" + networks: + - backend + volumes: + - "wordpress_content:/var/www/html/wp-content/" + secrets: + - source: backup_bot_ssh_key + mode: 0400 + - backup_bot_password + - db_password + configs: + - source: borgmatic_config_yml + target: /etc/borgmatic/config.yaml + environment: + - BORGBASE_REPO="g067e243@g067e243.repo.borgbase.com:repo" + - DB_HOST=mariadb + - DB_TABLE=wordpress + - DB_USER=wordpress + deploy: + mode: replicated + replicas: 0 + labels: + - "swarm.cronjob.enable=true" + - "swarm.cronjob.schedule=0 2 * * *" # At 02:00 + restart_policy: + condition: none + networks: + - backend + +configs: + borgmatic_config_yml: + name: borgmatic_config_yml_v7 + file: borgmatic.yml + template_driver: golang + +secrets: + backup_bot_ssh_key: + name: backup_bot_ssh_key_v1 + external: true + backup_bot_password: + name: backup_bot_password_v1 + external: true diff --git a/compose.yml b/compose.yml index 7526152..df8c3d6 100644 --- a/compose.yml +++ b/compose.yml @@ -48,34 +48,6 @@ services: - db_password - db_root_password - backupbot: - image: "decentral1se/backup-bot:0.0.1" - networks: - - backend - volumes: - - "wordpress_content:/var/www/html/wp-content/" - secrets: - - source: backup_bot_ssh_key - mode: 0400 - - backup_bot_password - - db_password - configs: - - source: borgmatic_config_yml - target: /etc/borgmatic/config.yaml - environment: - - BORGBASE_REPO="g067e243@g067e243.repo.borgbase.com:repo" - - DB_HOST=mariadb - - DB_TABLE=wordpress - - DB_USER=wordpress - deploy: - mode: replicated - replicas: 0 - labels: - - "swarm.cronjob.enable=true" - - "swarm.cronjob.schedule=0 2 * * *" # At 02:00 - restart_policy: - condition: none - networks: backend: driver: overlay @@ -86,11 +58,6 @@ volumes: mariadb: wordpress_content: -configs: - borgmatic_config_yml: - name: borgmatic_config_yml_v7 - file: borgmatic.yml - template_driver: golang secrets: db_root_password: @@ -99,9 +66,3 @@ secrets: db_password: external: true name: ${STACK_NAME}_db_password_${DB_ROOT_PASSWORD_VERSION} - backup_bot_ssh_key: - name: backup_bot_ssh_key_v1 - external: true - backup_bot_password: - name: backup_bot_password_v1 - external: true