Lets institute some operations around here

A directory for ops scripts, plus a script to backup the posgres
database that holds up asteroid.radio.
This commit is contained in:
Brian O'Reilly 2025-12-30 13:06:06 -05:00
parent de70fbde5a
commit a8bf864499
1 changed files with 19 additions and 0 deletions

19
docker/operations/db_backup.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
## Backup the postgresql instance running in our local
## asteroid-postgres docker container
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# Source the runtime environment for asteroid.radio. creds, paths &c
if [[ -f ${HOME}/SourceCode/lisp/asteroid/docker/environment.sh ]]; then
. ${HOME}/SourceCode/lisp/asteroid/docker/environment.sh
fi
BACKUP_DIR=${SCRIPT_DIR}/db_backups
mkdir -p "$BACKUP_DIR"
docker exec asteroid-postgres sh -c 'pg_dump $POSTGRES_DB -U $POSTGRES_USER -F p' | xz --compress -c > ${BACKUP_DIR}/db_$(date +%Y-%m-%d-%H.%M.%S)_backup.sql.xz