19 lines
789 B
Desktop File
19 lines
789 B
Desktop File
[Unit]
|
|
Description=PostgreSQL Cluster Backup Service
|
|
After=postgresql.service
|
|
BindsTo=postgresql.service
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
|
|
# logging
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
|
|
ExecStartPre=/usr/bin/podman exec postgresql sh -c "mkdir -p /backups/cluster && chown postgres:root /backups/cluster && chmod 770 /backups/cluster"
|
|
|
|
# Run the script
|
|
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c 'pg_dumpall -U postgres --schema-only | grep -v -E "CREATE ROLE postgres" > /backups/cluster/pg_cluster_$(date "+%%Y-%%m-%%d").sql'
|
|
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c "find /backups/cluster -maxdepth 1 -type f -mtime +7 -delete"
|
|
ExecStart=/usr/bin/podman exec postgresql sh -c "chown -R postgres:root /backups/cluster && chmod 660 /backups/cluster/*"
|