stillbox/util/dumpdb.sh

25 lines
379 B
Bash
Raw Permalink Normal View History

2024-11-13 19:40:24 -05:00
#!/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}"