Create postgresql backups without intermediate files
This commit is contained in:
parent
748cbed50d
commit
d840efa1e0
3 changed files with 7 additions and 20 deletions
|
@ -1,2 +1,3 @@
|
||||||
FROM restic/restic:0.17.3
|
FROM restic/restic:0.17.3
|
||||||
RUN apk add postgresql16-client
|
RUN apk add postgresql16-client
|
||||||
|
WORKDIR /data
|
||||||
|
|
|
@ -5,23 +5,6 @@
|
||||||
dest: /root/.pgpass
|
dest: /root/.pgpass
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
owner: root
|
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
|
- name: Run backup container
|
||||||
become: true
|
become: true
|
||||||
community.docker.docker_container:
|
community.docker.docker_container:
|
||||||
|
@ -33,9 +16,12 @@
|
||||||
AWS_SECRET_ACCESS_KEY: "{{ s3_secret_access_key }}"
|
AWS_SECRET_ACCESS_KEY: "{{ s3_secret_access_key }}"
|
||||||
AWS_DEFAULT_REGION: "{{ s3_region }}"
|
AWS_DEFAULT_REGION: "{{ s3_region }}"
|
||||||
RESTIC_PASSWORD: "{{ restic_password }}"
|
RESTIC_PASSWORD: "{{ restic_password }}"
|
||||||
|
networks:
|
||||||
|
- name: postgresql
|
||||||
entrypoint: ["sleep"]
|
entrypoint: ["sleep"]
|
||||||
command: ["infinity"]
|
command: ["infinity"]
|
||||||
volumes:
|
volumes:
|
||||||
|
- /root/.pgpass:/root/.pgpass:ro
|
||||||
- /mnt/hdd/archivebox-data:/data/archivebox:ro
|
- /mnt/hdd/archivebox-data:/data/archivebox:ro
|
||||||
- archivebox:/data/docker/archivebox:ro
|
- archivebox:/data/docker/archivebox:ro
|
||||||
- authentik-redis:/data/docker/authentik-redis:ro
|
- authentik-redis:/data/docker/authentik-redis:ro
|
||||||
|
@ -68,7 +54,6 @@
|
||||||
- peertube-redis:/data/docker/peertube-redis:ro
|
- peertube-redis:/data/docker/peertube-redis:ro
|
||||||
- /mnt/hdd/peertube:/data/peertube:ro
|
- /mnt/hdd/peertube:/data/peertube:ro
|
||||||
- phoenix:/data/docker/phoenix:ro
|
- phoenix:/data/docker/phoenix:ro
|
||||||
- postgresql-backups:/data/postgresql:ro
|
|
||||||
- prosody:/data/docker/prosody:ro
|
- prosody:/data/docker/prosody:ro
|
||||||
- synapse:/data/docker/synapse:ro
|
- synapse:/data/docker/synapse:ro
|
||||||
- vaultwarden:/data/docker/vaultwarden:ro
|
- vaultwarden:/data/docker/vaultwarden:ro
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
set -e
|
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 \
|
||||||
docker exec restic-1 restic --repo s3:https://{{ s3_host }}/{{ s3_bucket }} -o s3.bucket-lookup=dns backup /data/postgresql
|
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 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
|
docker exec restic-1 restic --repo s3:https://{{ s3_host }}/{{ s3_bucket }} -o s3.bucket-lookup=dns forget --keep-daily 7 --keep-weekly 2
|
||||||
|
|
Loading…
Reference in a new issue