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

@@ -52,7 +52,7 @@ esac
volumes_dir=/var/lib/docker/volumes
backup_dir="$volumes_dir/backup_datadir"
filename="backup.tar.gz"
dumpname="postgres.sql"
dumpname="postgres.sql.gz"
if [ "$BACKUP_TIMESTAMP" == true ]; then
timestamp=$(date "+%Y%m%d-%H%M%S")
@@ -66,9 +66,14 @@ dbdump_path="$backup_dir/_data/${dumpname}"
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
. helpers.sh
# ensure backup dir exists
if [ ! -d "$backup_dir" ]; then
docker volume create backup_datadir
fi
# dump database
echo "Dumping database …"
btcpay_dump_db $dumpname
btcpay_dump_db $dbdump_path
if [[ "$1" == "--only-db" ]]; then
tar -cvzf $backup_path $dbdump_path