Added db dump timer
This commit is contained in:
parent
deb8c3b985
commit
f8ffd95184
|
@ -41,3 +41,11 @@ ln -fs $HOME/nxy/files/nxy-bot.service $HOME/.config/systemd/user
|
|||
systemctl --user daemon-reload
|
||||
systemctl --user enable --now nxy-bot.service
|
||||
```
|
||||
|
||||
Create directory for database dumps and activate timer:
|
||||
```sh
|
||||
mkdir -p $HOME/backups
|
||||
ln -fs $HOME/nxy/files/nxy-db-dump.{timer,service} $HOME/.config/systemd/user
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable --now nxy-db-dump.timer
|
||||
```
|
||||
|
|
7
files/nxy-db-dump.service
Normal file
7
files/nxy-db-dump.service
Normal file
|
@ -0,0 +1,7 @@
|
|||
[Unit]
|
||||
Description=nxy database dump timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
WorkingDirectory=/home/nxy/backups
|
||||
ExecStart=/bin/sh -c "/usr/bin/pg_dump -d nxy_prod > $(date +%Y-%m-%d_%H-%M-%S).sql"
|
11
files/nxy-db-dump.timer
Normal file
11
files/nxy-db-dump.timer
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=nxy database dump timer
|
||||
|
||||
[Timer]
|
||||
# Time to wait after booting before we run first time
|
||||
OnBootSec=10min
|
||||
# Time between running each consecutive time
|
||||
OnUnitActiveSec=12h
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
Loading…
Reference in New Issue
Block a user