diff --git a/roles/backups/docker/Dockerfile b/roles/backups/docker/Dockerfile index 82d9830..2651248 100644 --- a/roles/backups/docker/Dockerfile +++ b/roles/backups/docker/Dockerfile @@ -1,2 +1,3 @@ FROM restic/restic:0.17.3 RUN apk add postgresql16-client +WORKDIR /data diff --git a/roles/backups/tasks/main.yml b/roles/backups/tasks/main.yml index 4974af0..bfde0bb 100644 --- a/roles/backups/tasks/main.yml +++ b/roles/backups/tasks/main.yml @@ -5,23 +5,6 @@ dest: /root/.pgpass mode: "0600" owner: root -- name: Create postgresql backups volume - become: true - community.docker.docker_volume: - name: postgresql-backups -- name: Run postgresql backuper - become: true - community.docker.docker_container: - name: postgresql-backuper-1 - image: git.comfycamp.space/lumin/postgres:16.4-bookworm - entrypoint: ["sleep"] - command: ["infinity"] - volumes: - - postgresql-backups:/backups - - /root/.pgpass:/root/.pgpass:ro - networks: - - name: postgresql - restart_policy: unless-stopped - name: Run backup container become: true community.docker.docker_container: @@ -33,9 +16,12 @@ AWS_SECRET_ACCESS_KEY: "{{ s3_secret_access_key }}" AWS_DEFAULT_REGION: "{{ s3_region }}" RESTIC_PASSWORD: "{{ restic_password }}" + networks: + - name: postgresql entrypoint: ["sleep"] command: ["infinity"] volumes: + - /root/.pgpass:/root/.pgpass:ro - /mnt/hdd/archivebox-data:/data/archivebox:ro - archivebox:/data/docker/archivebox:ro - authentik-redis:/data/docker/authentik-redis:ro @@ -68,7 +54,6 @@ - peertube-redis:/data/docker/peertube-redis:ro - /mnt/hdd/peertube:/data/peertube:ro - phoenix:/data/docker/phoenix:ro - - postgresql-backups:/data/postgresql:ro - prosody:/data/docker/prosody:ro - synapse:/data/docker/synapse:ro - vaultwarden:/data/docker/vaultwarden:ro diff --git a/roles/backups/templates/backup.sh.j2 b/roles/backups/templates/backup.sh.j2 index fa80db8..9ff724a 100644 --- a/roles/backups/templates/backup.sh.j2 +++ b/roles/backups/templates/backup.sh.j2 @@ -2,7 +2,8 @@ set -e -docker exec postgresql-backuper-1 pg_dumpall -U postgres -h postgresql --no-password -f /backups/postgresql.sql -docker exec restic-1 restic --repo s3:https://{{ s3_host }}/{{ s3_bucket }} -o s3.bucket-lookup=dns backup /data/postgresql +docker exec restic-1 restic --repo s3:https://{{ s3_host }}/{{ s3_bucket }} -o s3.bucket-lookup=dns \ + backup --stdin-filename /data/postgresql.sql --stdin-from-command \ + -- pg_dumpall -U postgres -h postgresql --no-password docker exec restic-1 restic --repo s3:https://{{ s3_host }}/{{ s3_bucket }} -o s3.bucket-lookup=dns backup /data/immich docker exec restic-1 restic --repo s3:https://{{ s3_host }}/{{ s3_bucket }} -o s3.bucket-lookup=dns forget --keep-daily 7 --keep-weekly 2