1
1
sovereign-stack/deployment/btcpayserver/backup_btcpay.sh

33 lines
1.4 KiB
Bash
Raw Normal View History

2022-06-22 17:39:46 +00:00
#!/bin/bash
2022-07-27 16:38:33 +00:00
set -exo
cd "$(dirname "$0")"
2022-06-22 17:39:46 +00:00
# take the services down, create a backup archive, then pull it down.
2022-07-27 16:38:33 +00:00
# the script executed here from the BTCPAY repo will automatically take services down
# and bring them back up.
2022-10-26 23:33:43 +00:00
echo "INFO!!!!!!!!!!! IN BTCPAY BACKUP SCRIPT."
sleep 4
2022-08-03 14:53:11 +00:00
ssh "$FQDN" "mkdir -p $REMOTE_HOME/backups; cd $REMOTE_HOME/; sudo BTCPAY_BASE_DIRECTORY=$REMOTE_HOME bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
2022-07-27 16:38:33 +00:00
# TODO enable encrypted archives
# TODO switch to btcpay-backup.sh when on LXD fully.
2022-07-29 22:33:24 +00:00
scp ./remote_scripts/btcpay-backup.sh "$FQDN:$REMOTE_HOME/btcpay-backup.sh"
2022-07-27 16:38:33 +00:00
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 "$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.
2022-06-22 17:39:46 +00:00
ssh "$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"
2022-07-27 16:38:33 +00:00
2022-10-26 23:33:43 +00:00
LOCAL_BACKUP_PATH="$SITE_PATH/backups/btcpayserver/$BACKUP_TIMESTAMP"
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"