Updates to btcpayserver backup/restore.
This commit is contained in:
parent
5455237f1f
commit
257034761d
25
deploy.sh
25
deploy.sh
@ -24,20 +24,18 @@ if ! lsb_release -d | grep -q "Ubuntu 22.04"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
DOMAIN_NAME=
|
DOMAIN_NAME=
|
||||||
|
|
||||||
VPS_HOSTING_TARGET=lxd
|
VPS_HOSTING_TARGET=lxd
|
||||||
RUN_CERT_RENEWAL=false
|
RUN_CERT_RENEWAL=false
|
||||||
|
SKIP_WWW=false
|
||||||
RESTORE_WWW=false
|
RESTORE_WWW=false
|
||||||
BACKUP_CERTS=true
|
BACKUP_CERTS=true
|
||||||
BACKUP_APPS=false
|
BACKUP_APPS=true
|
||||||
BACKUP_BTCPAY=false
|
BACKUP_BTCPAY=true
|
||||||
|
|
||||||
RESTORE_BTCPAY=false
|
RESTORE_BTCPAY=false
|
||||||
BTCPAY_RESTORE_ARCHIVE_PATH=
|
BTCPAY_RESTORE_ARCHIVE_PATH=
|
||||||
|
BTCPAY_LOCAL_BACKUP_PATH=
|
||||||
MIGRATE_WWW=false
|
MIGRATE_WWW=false
|
||||||
MIGRATE_BTCPAY=false
|
MIGRATE_BTCPAY=false
|
||||||
SKIP_WWW=false
|
|
||||||
SKIP_BTCPAY=false
|
SKIP_BTCPAY=false
|
||||||
UPDATE_BTCPAY=false
|
UPDATE_BTCPAY=false
|
||||||
RECONFIGURE_BTCPAY_SERVER=false
|
RECONFIGURE_BTCPAY_SERVER=false
|
||||||
@ -106,6 +104,7 @@ for i in "$@"; do
|
|||||||
;;
|
;;
|
||||||
--migrate-btcpay)
|
--migrate-btcpay)
|
||||||
MIGRATE_BTCPAY=true
|
MIGRATE_BTCPAY=true
|
||||||
|
BACKUP_BTCPAY=true
|
||||||
RUN_CERT_RENEWAL=false
|
RUN_CERT_RENEWAL=false
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -125,6 +124,12 @@ for i in "$@"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# do some CLI checking.
|
||||||
|
if [ "$RESTORE_BTCPAY" = true ] && [ ! -f "$BTCPAY_RESTORE_ARCHIVE_PATH" ]; then
|
||||||
|
echo "ERROR: The restoration archive is not specified. Ensure --restore-archive= is set on the command line."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# set up our default paths.
|
# set up our default paths.
|
||||||
source ./defaults.sh
|
source ./defaults.sh
|
||||||
|
|
||||||
@ -326,6 +331,8 @@ function instantiate_vms {
|
|||||||
export VIRTUAL_MACHINE="$VIRTUAL_MACHINE"
|
export VIRTUAL_MACHINE="$VIRTUAL_MACHINE"
|
||||||
export REMOTE_CERT_DIR="$REMOTE_CERT_BASE_DIR/$FQDN"
|
export REMOTE_CERT_DIR="$REMOTE_CERT_BASE_DIR/$FQDN"
|
||||||
export MAC_ADDRESS_TO_PROVISION="$MAC_ADDRESS_TO_PROVISION"
|
export MAC_ADDRESS_TO_PROVISION="$MAC_ADDRESS_TO_PROVISION"
|
||||||
|
export BTCPAY_LOCAL_BACKUP_PATH="$SITE_PATH/backups/btcpayserver/$BACKUP_TIMESTAMP"
|
||||||
|
export BTCPAY_LOCAL_BACKUP_ARCHIVE_PATH="$BTCPAY_LOCAL_BACKUP_PATH/$UNIX_BACKUP_TIMESTAMP.tar.gz"
|
||||||
|
|
||||||
# This next section of if statements is our sanity checking area.
|
# This next section of if statements is our sanity checking area.
|
||||||
if [ "$VPS_HOSTING_TARGET" = aws ]; then
|
if [ "$VPS_HOSTING_TARGET" = aws ]; then
|
||||||
@ -381,12 +388,12 @@ function instantiate_vms {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$MIGRATE_VPS" = true ]; then
|
if [ "$MIGRATE_VPS" = true ]; then
|
||||||
echo "INFO: User has indicated to delete the machine, but it doesn't exist."
|
echo "INFO: User has indicated a migration, but it doesn't exist. Try removing some command line arguments."
|
||||||
echo " Going to create it anyway."
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The machine does not exist. Let's bring it into existence, restoring from latest backup.
|
# The machine does not exist. Let's bring it into existence, restoring from latest backup.
|
||||||
echo "Machine does not exist."
|
echo "Machine does not exist. Creating."
|
||||||
./deployment/deploy_vms.sh
|
./deployment/deploy_vms.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,33 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exo
|
set -ex
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
# take the services down, create a backup archive, then pull it down.
|
# take the services down, create a backup archive, then pull it down.
|
||||||
# the script executed here from the BTCPAY repo will automatically take services down
|
# the script executed here from the BTCPAY repo will automatically take services down
|
||||||
# and bring them back up.
|
# and bring them back up.
|
||||||
|
|
||||||
echo "INFO!!!!!!!!!!! IN BTCPAY BACKUP SCRIPT."
|
echo "INFO: Starting BTCPAY Backup script for host '$BTCPAY_FQDN'."
|
||||||
sleep 4
|
|
||||||
|
|
||||||
|
ssh "$BTCPAY_FQDN" "mkdir -p $REMOTE_HOME/backups; 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 enable encrypted archives
|
||||||
# TODO switch to btcpay-backup.sh when on LXD fully.
|
# TODO switch to btcpay-backup.sh when on LXD fully.
|
||||||
scp ./remote_scripts/btcpay-backup.sh "$FQDN:$REMOTE_HOME/btcpay-backup.sh"
|
scp ./remote_scripts/btcpay-backup.sh "$BTCPAY_FQDN:$REMOTE_HOME/btcpay-backup.sh"
|
||||||
ssh "$FQDN" "sudo cp $REMOTE_HOME/btcpay-backup.sh $BTCPAY_SERVER_APPPATH/btcpay-backup.sh && sudo chmod 0755 $BTCPAY_SERVER_APPPATH/btcpay-backup.sh"
|
ssh "$BTCPAY_FQDN" "sudo cp $REMOTE_HOME/btcpay-backup.sh $BTCPAY_SERVER_APPPATH/btcpay-backup.sh && sudo chmod 0755 $BTCPAY_SERVER_APPPATH/btcpay-backup.sh"
|
||||||
ssh "$FQDN" "cd $REMOTE_HOME/; sudo BTCPAY_BASE_DIRECTORY=$REMOTE_HOME BTCPAY_DOCKER_COMPOSE=$REMOTE_HOME/btcpayserver-docker/Generated/docker-compose.generated.yml bash -c $BTCPAY_SERVER_APPPATH/btcpay-backup.sh"
|
ssh "$BTCPAY_FQDN" "cd $REMOTE_HOME/; sudo BTCPAY_BASE_DIRECTORY=$REMOTE_HOME BTCPAY_DOCKER_COMPOSE=$REMOTE_HOME/btcpayserver-docker/Generated/docker-compose.generated.yml bash -c $BTCPAY_SERVER_APPPATH/btcpay-backup.sh"
|
||||||
|
|
||||||
# next we pull the resulting backup archive down to our management machine.
|
# next we pull the resulting backup archive down to our management machine.
|
||||||
ssh "$FQDN" "sudo cp /var/lib/docker/volumes/backup_datadir/_data/backup.tar.gz $REMOTE_HOME/backups/btcpay.tar.gz"
|
ssh "$BTCPAY_FQDN" "sudo cp /var/lib/docker/volumes/backup_datadir/_data/backup.tar.gz $REMOTE_HOME/backups/btcpay.tar.gz"
|
||||||
ssh "$FQDN" "sudo chown ubuntu:ubuntu $REMOTE_HOME/backups/btcpay.tar.gz"
|
ssh "$BTCPAY_FQDN" "sudo chown ubuntu:ubuntu $REMOTE_HOME/backups/btcpay.tar.gz"
|
||||||
|
|
||||||
|
|
||||||
|
mkdir -p "$BTCPAY_LOCAL_BACKUP_PATH"
|
||||||
|
scp "$BTCPAY_FQDN:$REMOTE_HOME/backups/btcpay.tar.gz" "$BTCPAY_LOCAL_BACKUP_ARCHIVE_PATH"
|
||||||
|
|
||||||
LOCAL_BACKUP_PATH="$SITE_PATH/backups/btcpayserver/$BACKUP_TIMESTAMP"
|
echo "INFO: Created backup archive '$BTCPAY_LOCAL_BACKUP_ARCHIVE_PATH' for host '$BTCPAY_FQDN'."
|
||||||
mkdir -p "$LOCAL_BACKUP_PATH"
|
|
||||||
scp "$FQDN:$REMOTE_HOME/backups/btcpay.tar.gz" "$LOCAL_BACKUP_PATH/$UNIX_BACKUP_TIMESTAMP.tar.gz"
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
echo "EXITING SCRIPT"
|
|
||||||
|
@ -67,9 +67,6 @@ fi
|
|||||||
cd "$btcpay_dir"
|
cd "$btcpay_dir"
|
||||||
. helpers.sh
|
. helpers.sh
|
||||||
|
|
||||||
#echo "INFO: Stopping BTCPay Server."
|
|
||||||
#btcpay_down
|
|
||||||
|
|
||||||
cd "$restore_dir"
|
cd "$restore_dir"
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ elif [ "$VPS_HOSTING_TARGET" = lxd ]; then
|
|||||||
# create a base image if needed and instantiate a VM.
|
# create a base image if needed and instantiate a VM.
|
||||||
if [ -z "$MAC_ADDRESS_TO_PROVISION" ]; then
|
if [ -z "$MAC_ADDRESS_TO_PROVISION" ]; then
|
||||||
echo "ERROR: You MUST define a MAC Address for all your machines by setting WWW_SERVER_MAC_ADDRESS, BTCPAYSERVER_MAC_ADDRESS in your site defintion."
|
echo "ERROR: You MUST define a MAC Address for all your machines by setting WWW_SERVER_MAC_ADDRESS, BTCPAYSERVER_MAC_ADDRESS in your site defintion."
|
||||||
echo "INFO: IMPORTANT! You MUST have DHCP Reservations for these MAC addresses. You also need static DNS entries."
|
echo "INFO: IMPORTANT! You MUST have DHCP Reservations for these MAC addresses. You also need records established the DNS."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user