Simplify. Emphasis on the 'simp'.

This commit is contained in:
Jeffrey Serio 2024-06-24 16:41:22 -05:00
parent 99c42f9247
commit 521c1f9a82
7 changed files with 42 additions and 45 deletions

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
DB_FILENAME="/home/mastodon/db-backup-$(date '+%Y-%m-%d').sql"
if ! pg_dump -U mastodon mastodon_production -p 5432 -f "$DB_FILENAME"; then
echo "Error creating backup of mastodon_production database"
exit 1
else
echo "Backup of mastodon_production database completed"
fi
find /home/mastodon \
-maxdepth 1 \
-type f \
\( -name "*.sql" -and -not -wholename "$DB_FILENAME" \) \
-delete
exit 0

33
bin/mastodon-to-minio Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
DB_FILENAME="/home/mastodon/db-backup-$(date '+%Y-%m-%d').sql"
if ! pg_dump -U mastodon -Fc mastodon_production -p 5432 -f "$DB_FILENAME"; then
echo "Error creating backup of mastodon_production database"
exit 1
else
echo "Backup of mastodon_production database completed"
fi
find /home/mastodon \
-maxdepth 1 \
-type f \
\( -name "*.sql" -and -not -wholename "$DB_FILENAME" \) \
-delete
if ! rclone copy --transfers=4 /home/mastodon/live/public/system minio:mastodata; then
echo "Error rcloning /home/mastodon/live/public/system to MinIO instance"
exit 1
fi
if ! rclone copy "/home/mastodon/${DB_FILENAME}" minio:mastodata; then
echo "Error rcloning /home/mastodon/${DB_FILENAME} to MinIO instance"
exit 1
fi
if ! rclone copy /home/mastodon/live/.env.production minio:mastodata; then
echo "Error rcloning /home/mastodon/live/.env.production to MinIO instance"
exit 1
fi
exit 0

View File

@ -85,7 +85,11 @@ archivebox-setup:
cd {{archivebox_data}} && archivebox setup cd {{archivebox_data}} && archivebox setup
mastodon-aux-setup: mastodon-aux-setup:
sudo apt install -y rclone sudo cp -v "${PWD}/bin/mastodon-to-minio" /usr/local/bin/
sudo chmod +x /usr/local/bin/mastodon-to-minio
sudo cp -v "${PWD}/systemd/system/mastodon-to-minio.service" /etc/systemd/system/
sudo cp -v "${PWD}/systemd/system/mastodon-to-minio.timer" /etc/systemd/system/
sudo systemctl enable --now mastodon-to-minio.timer
thelounge-install: thelounge-install:
curl -s https://api.github.com/repos/thelounge/thelounge-deb/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi - curl -s https://api.github.com/repos/thelounge/thelounge-deb/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi -

View File

@ -1,14 +0,0 @@
[Unit]
Description=mastodon-db-backup
Wants=postgresql.service
AssertFileIsExecutable=/usr/local/bin/mastodon-db-backup
[Service]
Type=oneshot
User=mastodon
Group=mastodon
WorkingDirectory=/home/mastodon
ExecStart=/usr/local/bin/mastodon-db-backup
[Install]
WantedBy=multi-user.target

View File

@ -1,9 +0,0 @@
[Unit]
Description=mastodon-db-backup
[Timer]
OnCalendar=*-*-* 21:00:00
Persistent=true
[Install]
WantedBy=timers.target

View File

@ -1,13 +1,14 @@
[Unit] [Unit]
Description=mastodon-to-minio Description=mastodon-to-minio
Wants=network.target Wants=postgresql.service
AssertFileIsExecutable=/usr/local/bin/mastodon-to-minio
[Service] [Service]
Type=oneshot Type=oneshot
User=mastodon User=mastodon
Group=mastodon Group=mastodon
WorkingDirectory=/home/mastodon WorkingDirectory=/home/mastodon
ExecStart=rclone copy --progress --transfers=8 /home/mastodon/ minio:mastodata ExecStart=/usr/local/bin/mastodon-to-minio
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -2,7 +2,7 @@
Description=mastodon-to-minio Description=mastodon-to-minio
[Timer] [Timer]
OnCalendar=*-*-* 22:00:00 OnCalendar=*-*-* 21:00:00
Persistent=true Persistent=true
[Install] [Install]