1
0

Backup and restore process (#641)

* Make db dump more modular

* Add basic backup and restore scripts

* Exit on error

* Exit with error code in case of missing file

* Determine volumes location programatically

A bit hacky, maybe there's a better way - open for suggestions!

* gzip database dump

* Restore database

* Fail on pipe errors

* Encrypt backup using gpg; improve log messages

* Ensure database container is up during dump and import

* Restore volumes
This commit is contained in:
d11n
2022-06-02 09:43:05 +02:00
committed by GitHub
parent f2a0f889f5
commit e87ef5d0b0
4 changed files with 256 additions and 8 deletions

View File

@@ -175,11 +175,7 @@ btcpay_restart() {
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"
local file_path=${1:-"postgres-$(date "+%Y%m%d-%H%M%S").sql.gz"}
docker exec $(docker ps -a -q -f "name=postgres_1") pg_dumpall -c -U postgres | gzip > "$file_path"
popd > /dev/null
}