From c4ed18059252585ccdcd7aa21f911765f2f56c39 Mon Sep 17 00:00:00 2001 From: skobkin Date: Wed, 6 Nov 2024 20:33:37 +0000 Subject: [PATCH] postgresql_backup. Systemd configuration. --- postgresql_backup/README.md | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/postgresql_backup/README.md b/postgresql_backup/README.md index ddd3497..72d4e66 100644 --- a/postgresql_backup/README.md +++ b/postgresql_backup/README.md @@ -14,4 +14,44 @@ Example ```properties localhost:5432:*:postgres:pg_password_1 localhost:5433:*:postgres:pg_password_2 +``` + +## Scheduling + +### Systemd + +#### Service + +`/etc/systemd/system/postgresql_backup.service` + +```ini +[Unit] +Description=PostgreSQL backup Script + +[Service] +Type=oneshot +WorkingDirectory=/root/scripts/postgresql_backup +ExecStart=/root/scripts/postgresql_backup/pg_backup.sh +``` + +#### Timer + +`/etc/systemd/system/postgresql_backup.timer` + +```ini +[Unit] +Description=Run Backup Script Every Night + +[Timer] +OnCalendar=*-*-* 22:00:00 +Unit=postgresql_backup.service + +[Install] +WantedBy=timers.target +``` + +Then: + +```shell +systemctl enable postgresql_backup.timer --now ``` \ No newline at end of file