stillbox/util/dumpdb.sh
2024-11-15 10:41:04 -05:00

24 lines
379 B
Bash

#!/bin/sh
config=config.yaml
pgformat="-Fc"
ext=pgdump
while getopts ":p" arg; do
case $arg in
c)
config=$OPTARG
;;
p)
pgformat="-Fp"
ext=sql
;;
esac
done
filen=`date "+backups/%Y%m%d_%H%M%S.${ext}"`
mkdir -p backups/
dbstring=`yq -r .db.connect "${config}"`
pg_dump "${pgformat}" -f "${filen}" -T calls "${dbstring}"
echo "backed up to ${filen}"