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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user