postgresql_backup. Systemd configuration.
This commit is contained in:
parent
f2dff8632f
commit
c4ed180592
|
@ -15,3 +15,43 @@ Example
|
||||||
localhost:5432:*:postgres:pg_password_1
|
localhost:5432:*:postgres:pg_password_1
|
||||||
localhost:5433:*:postgres:pg_password_2
|
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
|
||||||
|
```
|
Loading…
Reference in a new issue