Skip to content
Snippets Groups Projects
Verified Commit 6a3b827c authored by Nick Sellen's avatar Nick Sellen
Browse files

Remove backup script

Backups are handled elsewhere now
parent 196ba2d6
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# A script which backs up the mastodon database(s)
set -o pipefail
set -e
container=db
backupdir=/opt/backups/postgres
# This performs a cyclic dump to files with the container and date in the name
# It also creates a link to a file containing the backup sequence number 0 or 1
# which alternates (computed by modular division from the days since the epoch).
# Thus by deleting the linked file we can maintain just two backup files.
backup() {
local cname=$1
local seqno="$(( $(date +%s) / 86400 % 2 ))"
local link="db-backup.$seqno.sql.gz"
local file="db-backup.$(date +%F_%R)-${cname}.sql.gz"
echo "Backing up $cname -> $file @ $(date +%F_%R)"
# delete previous backup with same seqno, don't complain if missing
rm -f $(readlink -f "$backupdir/$link")
# create new backup file
docker-compose -f /opt/social.coop/sauce/docker/docker-compose.yml exec -T "$cname" pg_dumpall -U postgres -c -v | gzip >"$backupdir/$file"
status=$?
# link the sequence number to it
ln -sf "$backupdir/"{"$file","$link"}
echo "Done. (Status $status @$(date +%F_%R))"
}
# Iterate over all matching container names
#for cname in $(docker container ls -f name=$container --format '{{.Names}}')
#do
backup $container
#done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment