2022-06-22 17:39:46 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-07-27 16:38:33 +00:00
|
|
|
set -ex
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2022-07-29 22:30:33 +00:00
|
|
|
if [ -f "$RESTORE_ARCHIVE" ]; then
|
2022-07-27 16:38:33 +00:00
|
|
|
# push the restoration archive to the remote server
|
2022-07-29 22:30:33 +00:00
|
|
|
echo "INFO: Restoring BTCPAY Server: $RESTORE_ARCHIVE"
|
2022-06-22 17:39:46 +00:00
|
|
|
ssh "$FQDN" mkdir -p "$REMOTE_BACKUP_PATH"
|
2022-07-27 16:38:33 +00:00
|
|
|
REMOTE_BTCPAY_ARCHIVE_PATH="$REMOTE_HOME/backups/btcpay.tar.gz"
|
2022-07-29 22:30:33 +00:00
|
|
|
scp "$RESTORE_ARCHIVE" "$FQDN:$REMOTE_BTCPAY_ARCHIVE_PATH"
|
2022-07-27 16:38:33 +00:00
|
|
|
|
2022-07-29 22:30:33 +00:00
|
|
|
# we clean up any old containers first before restoring.
|
|
|
|
ssh "$FQDN" docker system prune -f
|
2022-07-27 16:38:33 +00:00
|
|
|
|
|
|
|
# push the modified restore script to the remote directory, set permissions, and execute.
|
2022-07-29 22:30:33 +00:00
|
|
|
scp ./remote_scripts/btcpay-restore.sh "$FQDN:$REMOTE_HOME/btcpay-restore.sh"
|
2022-07-27 16:38:33 +00:00
|
|
|
ssh "$FQDN" "sudo mv $REMOTE_HOME/btcpay-restore.sh $BTCPAY_SERVER_APPPATH/btcpay-restore.sh && sudo chmod 0755 $BTCPAY_SERVER_APPPATH/btcpay-restore.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-restore.sh $REMOTE_BTCPAY_ARCHIVE_PATH'"
|
|
|
|
|
2022-07-29 22:30:33 +00:00
|
|
|
# now, we're going to take things down because aparently we this needs to be re-exececuted.
|
|
|
|
ssh "$FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
|
|
|
|
|
2022-06-22 17:39:46 +00:00
|
|
|
else
|
|
|
|
echo "ERROR: File does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|