Init and added backup stuff for mastodon
This commit is contained in:
commit
481d797c72
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# A small set of server-side utilities
|
||||||
|
|
||||||
|
Divided by server.
|
25
mastodon/README.md
Normal file
25
mastodon/README.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Utilities to keep mastodon instance clean (and hopefully running)
|
||||||
|
|
||||||
|
## Postgres backup
|
||||||
|
|
||||||
|
(All the mastodon installation is in `/home/mastodon/live` running as `mastodon`).
|
||||||
|
|
||||||
|
Create a `/home/mastodon/.bin` directory and place there the backup script (`dobackup.sh`)
|
||||||
|
Create also:
|
||||||
|
|
||||||
|
- `/home/mastodon/.bu`
|
||||||
|
- `/home/mastodon/.bu/monthly`
|
||||||
|
|
||||||
|
Then place in (assuming we are on a debian-like distro) `/lib/systemd/system` the following:
|
||||||
|
|
||||||
|
- `pg_backup_daily.service`
|
||||||
|
- `pg_backup_daily.timer`
|
||||||
|
- `pg_backup_monthly.service`
|
||||||
|
- `pg_backup_monthly.timer`
|
||||||
|
|
||||||
|
|
||||||
|
And start them (as root):
|
||||||
|
|
||||||
|
```
|
||||||
|
$ systemctl enable pg_backup_*.timer
|
||||||
|
```
|
5
mastodon/dobackup.sh
Executable file
5
mastodon/dobackup.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BUDIR="/home/mastodon/.bu/"
|
||||||
|
|
||||||
|
pg_dump mastodon_production > "${BUDIR}/$(date +%Y%m%d)-mastodon_production.sql"
|
8
mastodon/pg_backup_daily.service
Normal file
8
mastodon/pg_backup_daily.service
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Backup postgres database mastodon_production
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=mastodon
|
||||||
|
Group=mastodon
|
||||||
|
ExecStart=/home/mastodon/.bin/dobackup.sh
|
9
mastodon/pg_backup_daily.timer
Normal file
9
mastodon/pg_backup_daily.timer
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Backup postgres database mastodon_production
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=daily
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
8
mastodon/pg_backup_monthly.service
Normal file
8
mastodon/pg_backup_monthly.service
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Backup postgres database mastodon_production (monthly)
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=mastodon
|
||||||
|
Group=mastodon
|
||||||
|
ExecStart=/bin/bash -c "mv $(ls -rt /home/mastodon/.bu/*.sql|tail -1) /home/mastodon/.bu/monthly/"
|
9
mastodon/pg_backup_monthly.timer
Normal file
9
mastodon/pg_backup_monthly.timer
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Backup postgres database mastodon_production (monthly)
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=monthly
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
Loading…
Reference in New Issue
Block a user