Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Daily Postgresql Backup by systemd
[Unit]
Description=Daily PG Backup
Documentation=man:pg_dump(8)
ConditionACPower=true
After=postgresql.service network.target network-online.target systemd-networkd.service NetworkManager.service connman.service
[Service]
Type=oneshot
User=postgres
Group=postgres
ExecStart=/usr/bin/pg_dump --dbname=app_db --format=c --jobs=1 --compress=3 --verbose --create --file=/var/backups/postgresql/app_db.sql
KillMode=process
TimeoutStopSec=900
[Unit]
Description=Daily PG Backup
After=database-daily-backup.timer
[Timer]
OnCalendar=*-*-* 02:00
RandomizedDelaySec=10m
Persistent=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment