Skip to content

Instantly share code, notes, and snippets.

View TheAlienKnight's full-sized avatar

AlienKnight TheAlienKnight

View GitHub Profile
#!/bin/bash
status_code=$(curl --write-out %{http_code} --silent --output /dev/null https://server.tld)
logfile=bandaid-log-$(date -I).txt
if [[ "$status_code" -ne 200 ]] ; then
touch $logfile # This is only here for the sake of compatibility
echo "[$(date +%s)][Bandaid] Site status changed to $status_code" >> $logfile
echo "[$(date +%s)][Bandaid] Saving mastodon container logs for evaluation..." >> $logfile
tmp=$(date +%F_%T)
docker compose logs --since 5m > docker-bandaid-log-$(date +%F_%T).txt # This grabs *all* the container logs in docker-compose.yml, to help evaluate the root cause
echo "[$(date +%s)][Bandaid] Saved to docker-bandaid-log-$(tmp).txt" >> $logfile
@TheAlienKnight
TheAlienKnight / v4.0.0-migration.sh
Last active November 23, 2022 00:31
v3.5.3 to v4.0.0 - Mastodon Docker Migration
#!/bin/bash
echo "Creating backup folder if one doesn't exist already..."
mkdir -p ./backups/3.5.3/
echo "Backing up the Mastodon Database"
docker exec mastodon-db-1 pg_dump -Fc -U postgres postgres > ./backups/3.5.3/pg-3.5.3.dump
echo "Assuming docker-compose.yml exists in this directory, replacing v3.5.3 with v4.0.0"
sed -i 's/v3.5.3/v4.0.0/g' docker-compose.yml
echo "Pulling new versions from dockerhub"
docker compose pull
echo "Performing Pre-deployment database migrations..."