diff --git a/id.tjo.space/root/etc/systemd/system/postgresql-backup.service b/id.tjo.space/root/etc/systemd/system/postgresql-backup.service index 4746fcc..9f198e7 100644 --- a/id.tjo.space/root/etc/systemd/system/postgresql-backup.service +++ b/id.tjo.space/root/etc/systemd/system/postgresql-backup.service @@ -1,5 +1,11 @@ [Unit] Description=Backup PostgreSQL databases +Requires=main-network.service +Requires=postgresql.service +After=main-network.service +After=postgresql.service +RequiresMountsFor=/srv/postgresql/backup +RequiresMountsFor=%t/containers [Service] Delegate=yes @@ -14,11 +20,12 @@ EnvironmentFile=/etc/postgresql/postgresql.env Environment=BACKUP_DIR=/srv/postgresql/backups Environment=POSTGRES_HOST=systemd-postgresql -ExecStartPre=/usr/bin/systemd stop authentik-server authentik-worker +ExecStartPre=/usr/bin/systemctl stop authentik-server authentik-worker ExecStartPre=/usr/bin/mkdir -p $BACKUP_DIR ExecStart=/usr/bin/podman run --name=systemd-%N --cidfile=%t/%N.cid --cgroups=split --sdnotify=conmon --detach --replace --rm --network systemd-main -v ${BACKUP_DIR}:/backups -e PGPASSWORD=${POSTGRES_PASSWORD} docker.io/library/postgres:17.4 pg_dump --username=${POSTGRES_USER} --host=${POSTGRES_HOST} --format=custom --file=/backups/${CURRENT_DATETIME}.sql ${POSTGRES_DB} ExecStop=/usr/bin/podman rm -v -f -i --cidfile=%t/%N.cid + ExecStopPost=-/usr/bin/podman rm -v -f -i --cidfile=%t/%N.cid -ExecStopPost=/usr/bin/systemd start authentik-server authentik-worker +ExecStopPost=/usr/bin/systemctl start authentik-server authentik-worker