1
0

Improve and document backup script, add scp option (#429)

* Improve and document backup script, add scp option

* dump_db as helper function

* Add option to only dump the database
This commit is contained in:
d11n
2021-01-22 05:53:53 +01:00
committed by GitHub
parent 01899efd57
commit 8bd3b65b5a
3 changed files with 128 additions and 30 deletions

View File

@@ -145,4 +145,16 @@ btcpay_restart() {
docker-compose -f $BTCPAY_DOCKER_COMPOSE restart
fi
popd > /dev/null
}
}
btcpay_dump_db() {
pushd . > /dev/null
cd "$(dirname "$BTCPAY_ENV_FILE")"
backup_dir="/var/lib/docker/volumes/backup_datadir/_data"
if [ ! -d "$backup_dir" ]; then
docker volume create backup_datadir
fi
local filename=${1:-"postgres-$(date "+%Y%m%d-%H%M%S").sql"}
docker exec $(docker ps -a -q -f "name=postgres_1") pg_dumpall -c -U postgres > "$backup_dir/$filename"
popd > /dev/null
}