2025-03-08 21:09:50 +00:00
|
|
|
[Unit]
|
|
|
|
Description=Backup PostgreSQL databases
|
|
|
|
|
|
|
|
[Service]
|
2025-03-09 15:10:29 +00:00
|
|
|
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
|
|
|
|
|
2025-03-08 21:09:50 +00:00
|
|
|
EnvironmentFile=/etc/postgresql/secrets.env
|
|
|
|
EnvironmentFile=/etc/postgresql/postgresql.env
|
|
|
|
Environment=BACKUP_DIR=/srv/postgresql/backups
|
2025-03-09 14:57:59 +00:00
|
|
|
Environment=POSTGRES_HOST=systemd-postgresql
|
2025-03-09 15:10:29 +00:00
|
|
|
|
2025-03-09 14:57:59 +00:00
|
|
|
ExecStartPre=/usr/bin/mkdir -p $BACKUP_DIR
|
2025-03-09 15:12:49 +00:00
|
|
|
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 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
|