dcerberus_com_web1
has a user called aws-backup
that sends the following to an S3 bucket every day:
.env.production
file#!/bin/bash
set +x
DATE=`date +"%Y-%m-%d"`
# Postgres database
sudo -u postgres pg_dumpall | gzip > pgdump-${DATE}.sql.gz
/usr/local/bin/aws s3 cp pgdump-${DATE}.sql.gz s3://BUCKET/pgdump-${DATE}.sql.gz
sudo rm pgdump-${DATE}.sql.gz
# Redis backup
sudo aws s3 cp /var/lib/redis/dump.rdb s3://BUCKET/dump.rdb-${DATE}
# Mastodon config
sudo aws s3 cp /home/mastodon/live/.env.production s3://BUCKET/env.production-${DATE}
And is called by a local crontab entry for the aws-backup
user.
$ crontab -l | egrep -v "^#"
19 15 * * * /bin/bash /home/aws-backup/backup.sh
First, recover the latest instance from AMI snapshot in EC2. Then, recover the Redis and PostgreSQL databases, as well as the config file with the proper secrets contained therein, before using docker-compose
.
Stop Redis
service redis stop
Copy the most recent dump.rdb-*
file to /var/lib/redis/dump.rdb
.
Start Redis again.
service redis start
todo
Copy the latest .env.production
file to /home/mastodon/live
, and then restart all Mastodon services.