Add server0-backup

This commit is contained in:
Jeffrey Serio 2024-07-20 16:15:56 -05:00
parent f587c629e3
commit a346f8b1c6
10 changed files with 32 additions and 33 deletions

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -eu
trap "mv /home/mastodon/db-backup.sql.temp /home/mastodon/db-backup.sql" SIGHUP SIGINT SIGQUIT SIGTERM
trap "rm -v /home/mastodon/db-backup.sql.temp" EXIT
mv -v /home/mastodon/db-backup.sql /home/mastodon/db-backup.sql.temp
pg_dump -U mastodon -Fc mastodon_production -p 5432 -f /home/mastodon/db-backup.sql
rclone sync -c /home/mastodon/live/public/system/ /mnt/mastodon/system
rclone copy -c /home/mastodon/db-backup.sql /mnt/mastodon
rclone copy -c /home/mastodon/live/.env.production /mnt/mastodon
exit 0

17
bin/server0-backup Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -eu
trap "sudo -u mastodon mv /home/mastodon/db-backup.sql.temp /home/mastodon/db-backup.sql" SIGHUP SIGINT SIGQUIT SIGTERM
trap "rm -v /home/mastodon/db-backup.sql.temp" EXIT
sudo -u mastodon mv -v /home/mastodon/db-backup.sql /home/mastodon/db-backup.sql.temp
sudo -u mastodon pg_dump -U mastodon -Fc mastodon_production -p 5432 -f /home/mastodon/db-backup.sql
rclone sync -c /etc wasabi:server0-backup/etc/
rclone sync -c /var/log wasabi:server0-backup/var-log/
rclone sync -c /home/jas wasabi:server0-backup/home-jas/
rclone copy -c /home/mastodon/db-backup.sql wasabi:server0-backup/home-mastodon/
rclone copy -c /home/mastodon/live/.env.production wasabi:server0-backup/home-mastodon/
exit 0

View File

@ -1,14 +0,0 @@
[Unit]
Description=rsync-backup
AssertFileIsExecutable=/usr/local/bin/rsync-backup
Requires=mnt-backup.mount
After=mnt-backup.mount
[Service]
Type=oneshot
User=root
Group=root
ExecStart=/usr/local/bin/rsync-backup
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,14 @@
[Unit]
Description=server0-backup
AssertFileIsExecutable=/usr/local/bin/server0-backup
Requires=network-online.target
After=network-online.target
[Service]
Type=oneshot
User=root
Group=root
ExecStart=/usr/local/bin/server0-backup
[Install]
WantedBy=multi-user.target

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=rsync-backup Description=server0-backup
[Timer] [Timer]
OnCalendar=Sun *-*-* 23:30:00 OnCalendar=Sun *-*-* 23:30:00