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