1
1
Fork 1

BTCPAY Server migration improvements.

This commit is contained in:
Derek Smith 2022-08-03 10:53:11 -04:00
parent f80ef6f051
commit fc6d7fda90
Signed by: farscapian
GPG Key ID: 8F1CD799CCA516CC
6 changed files with 34 additions and 24 deletions

View File

@ -23,7 +23,7 @@ if ! lsb_release -d | grep -q "Ubuntu 22.04 LTS"; then
exit 1
fi
MIGRATE_VPS=false
MIGRATE_BTCPAY=false
DOMAIN_NAME=
RESTORE_ARCHIVE=
VPS_HOSTING_TARGET=lxd
@ -81,7 +81,7 @@ for i in "$@"; do
shift
;;
--migrate-btcpay)
MIGRATE_VPS=true
MIGRATE_BTCPAY=true
RUN_CERT_RENEWAL=false
shift
;;
@ -211,14 +211,15 @@ function run_domain {
export RUN_CERT_RENEWAL="$RUN_CERT_RENEWAL"
export BTC_CHAIN="$BTC_CHAIN"
export UPDATE_BTCPAY="$UPDATE_BTCPAY"
export MIGRATE_VPS="$MIGRATE_VPS"
export MIGRATE_BTCPAY="$MIGRATE_BTCPAY"
export RECONFIGURE_BTCPAY_SERVER="$RECONFIGURE_BTCPAY_SERVER"
# iterate over all our server endpoints and provision them if needed.
# www
VPS_HOSTNAME=
# OPTINOAL umbrel
for VIRTUAL_MACHINE in www btcpayserver umbrel; do
for VIRTUAL_MACHINE in www btcpayserver; do
FQDN=
# shellcheck disable=SC1091
@ -386,7 +387,7 @@ function run_domain {
if [ "$MACHINE_EXISTS" = true ]; then
# we delete the machine if the user has directed us to
if [ "$MIGRATE_VPS" = true ]; then
if [ "$MIGRATE_BTCPAY" = true ]; then
# if the RESTORE_ARCHIVE is not set, then
if [ -z "$RESTORE_ARCHIVE" ]; then
@ -422,13 +423,13 @@ function run_domain {
RESTORE_BTCPAY="$RESTORE_BTCPAY" UPDATE_BTCPAY="$UPDATE_BTCPAY" RUN_RESTORE="$USER_RUN_RESTORE" RUN_BACKUP="$RUN_BACKUP" RUN_SERVICES=true ./deployment/domain_init.sh
fi
else
if [ "$MIGRATE_VPS" = true ]; then
if [ "$MIGRATE_BTCPAY" = true ]; then
echo "INFO: User has indicated to delete the machine, but it doesn't exist. Going to create it anyway."
fi
# The machine does not exist. Let's bring it into existence, restoring from latest backup.
echo "Machine does not exist. RUN_RESTORE=$USER_RUN_RESTORE RUN_BACKUP=false"
RESTORE_BTCPAY=false UPDATE_BTCPAY="$UPDATE_BTCPAY" RUN_RESTORE="$USER_RUN_RESTORE" RUN_BACKUP=false RUN_SERVICES=true ./deployment/domain_init.sh
RESTORE_BTCPAY="$RESTORE_BTCPAY" UPDATE_BTCPAY="$UPDATE_BTCPAY" RUN_RESTORE="$USER_RUN_RESTORE" RUN_BACKUP=false RUN_SERVICES=true ./deployment/domain_init.sh
fi
done

View File

@ -7,7 +7,7 @@ cd "$(dirname "$0")"
# the script executed here from the BTCPAY repo will automatically take services down
# and bring them back up.
ssh "$FQDN" "cd $REMOTE_HOME/; sudo BTCPAY_BASE_DIRECTORY=$REMOTE_HOME bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
ssh "$FQDN" "mkdir -p $REMOTE_HOME/backups; cd $REMOTE_HOME/; sudo BTCPAY_BASE_DIRECTORY=$REMOTE_HOME bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
# TODO enable encrypted archives
# TODO switch to btcpay-backup.sh when on LXD fully.

View File

@ -24,11 +24,19 @@ elif [ "$RESTORE_BTCPAY" = true ]; then
RUN_SERVICES=true
OPEN_URL=true
# if this is a new VM from a migration procedure, then we can now run setup.
if [ "$MIGRATE_BTCPAY" = true ]; then
./stub_btcpay_setup.sh
fi
elif [ "$RECONFIGURE_BTCPAY_SERVER" == true ]; then
# the administrator may have indicated a reconfig;
# if so, we re-run setup script.
./run_setup.sh
exit
./stub_btcpay_setup.sh
RUN_BACKUP=false
RUN_SERVICES=true
OPEN_URL=true
fi
# if the script gets this far, then we grab a regular backup.
@ -37,7 +45,6 @@ if [ "$RUN_BACKUP" = true ]; then
./backup.sh "$UNIX_BACKUP_TIMESTAMP"
fi
if [ "$RUN_SERVICES" = true ]; then
# The default is to resume services, though admin may want to keep services off (eg., for a migration)
# we bring the services back up by default.
@ -48,6 +55,6 @@ fi
if [ "$OPEN_URL" = true ]; then
if wait-for-it -t 5 "$FQDN:443"; then
xdg-open "https://$FQDN"
xdg-open "https://$FQDN" > /dev/null 2>&1
fi
fi
fi

View File

@ -67,13 +67,17 @@ echo " Archiving files in $(pwd)…"
{
tar \
--exclude="volumes/backup_datadir" \
--exclude="volumes/generated_bitcoin_datadir/blocks" \
--exclude="volumes/generated_bitcoin_datadir/chainstate" \
--exclude="volumes/generated_bitcoin_datadir/debug.log" \
--exclude="volumes/generated_litecoin_datadir/blocks" \
--exclude="volumes/generated_litecoin_datadir/chainstate" \
--exclude="volumes/generated_litecoin_datadir/debug.log" \
--exclude="volumes/generated_bitcoin_datadir/_data/blocks" \
--exclude="volumes/generated_bitcoin_datadir/_data/chainstate" \
--exclude="volumes/generated_bitcoin_datadir/_data/debug.log" \
--exclude="volumes/generated_bitcoin_datadir/_data/testnet3/blocks" \
--exclude="volumes/generated_bitcoin_datadir/_data/testnet3/chainstate" \
--exclude="volumes/generated_bitcoin_datadir/_data/testnet3/debug.log" \
--exclude="volumes/generated_bitcoin_datadir/_data/regtest/blocks" \
--exclude="volumes/generated_bitcoin_datadir/_data/regtest/chainstate" \
--exclude="volumes/generated_bitcoin_datadir/_data/regtest/debug.log" \
--exclude="volumes/generated_postgres_datadir" \
--exclude="volumes/generated_tor_relay_datadir" \
--exclude="volumes/generated_clightning_bitcoin_datadir/_data/lightning-rpc" \
--exclude="**/logs/*" \
-cvzf "$backup_path" "$dbdump_name" volumes/generated_*

View File

@ -59,10 +59,9 @@ if [ "\$NBITCOIN_NETWORK" != regtest ]; then
fi
fi
# provision the btcpayserver
# run the setup script.
. ./btcpay-setup.sh -i
sleep 15
EOL
# send the setup script to the remote machine.

View File

@ -36,8 +36,7 @@ function prepare_host {
if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then
echo "INFO: new machine detected. Provisioning BTCPay server scripts."
./btcpayserver/run_setup.sh
./btcpayserver/stub_btcpay_setup.sh
fi
}