Skip to content
Snippets Groups Projects
Commit 745fd716 authored by nimrod's avatar nimrod
Browse files

Matrix: Add backups.

- Mark the Synapse data volume for snapshot by `dvb` (it just a bunch of
  files anyway).
- Do weekly backups of the database.
parent 0098b2c5
No related branches found
No related tags found
No related merge requests found
Pipeline #4252 failed
*
!backup
!crontab
# hadolint ignore=DL3006
FROM registry.shore.co.il/cron as supersonic
# hadolint ignore=DL3002
USER root
# hadolint ignore=DL3018
RUN apk add --update --no-cache \
docker-cli \
findutils \
;
COPY --chown=root:root backup /usr/local/bin/
COPY --chown=root:root restore /usr/local/bin/
VOLUME /var/backups
# crond
Runs background jobs for the Matrix server. The jobs are:
- Postgres DB backup.
#!/bin/sh
set -eu
now="$(date --utc -Iseconds)"
dest="/var/backups/${now}.sql.zstd"
mkdir --parents "$(dirname "$dest")"
docker exec matrix-postgres-1 backup > "$dest"
@weekly backup || wget --spider https://notify.shore.co.il/send?message=Matrix%20DB%20backup%20failed.
@daily find /var/backups -atime +18 -delete
......@@ -2,6 +2,16 @@
version: '3.5'
services:
cron:
build:
context: crond/
depends_on:
- postgres
restart: always
volumes:
- /run/docker.sock:/run/docker.sock
- /var/backups/matrix:/var/backups
postgres:
environment:
POSTGRES_DB: &postgres_db synapse
......@@ -39,6 +49,8 @@ services:
volumes:
data:
labels:
snapshot: 'true'
postgres:
_run_slapd:
external: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment