feat(id.tjo.space): simplify backup

This commit is contained in:
Tine 2025-03-09 16:10:29 +01:00
parent 71b2aad2d5
commit c91024154e
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw

View file

@ -2,11 +2,20 @@
Description=Backup PostgreSQL databases
[Service]
Type=oneshot
ExecStart=/usr/local/bin/postgresql-backup.sh
Restart=always
Environment=PODMAN_SYSTEMD_UNIT=%n
KillMode=mixed
ExecStop=/usr/bin/podman rm -v -f -i --cidfile=%t/%N.cid
ExecStopPost=-/usr/bin/podman rm -v -f -i --cidfile=%t/%N.cid
Delegate=yes
Type=notify
NotifyAccess=all
SyslogIdentifier=%N
EnvironmentFile=/etc/postgresql/secrets.env
EnvironmentFile=/etc/postgresql/postgresql.env
Environment=BACKUP_DIR=/srv/postgresql/backups
Environment=POSTGRES_HOST=systemd-postgresql
ExecStartPre=/usr/bin/mkdir -p $BACKUP_DIR
ExecStart=/usr/bin/podman run --rm --network systemd-main -v $BACKUP_DIR:/backups:z docker.io/library/postgres:17.4 pg_dumpall -U $POSTGRES_USER -h $POSTGRES_HOST -p $POSTGRES_PORT -f /backups/$(date +'%Y-%m-%d_%H-%M-%S').sql
ExecStart=/usr/bin/podman run --name=systemd-%N --cidfile=%t/%N.cid --replace --rm --cgroups=split --network systemd-main --sdnotify=conmon -d -v $BACKUP_DIR:/backups:z docker.io/library/postgres:17.4 pg_dumpall -U $POSTGRES_USER -h $POSTGRES_HOST -p $POSTGRES_PORT -f /backups/$(date +'%Y-%m-%d_%H-%M-%S').sql