# BTCPay Server Restoration Guide

## Prerequisites
- Fresh Debian 13 server
- Root access
- At least 50GB free disk space
- Domain name pointed to server IP

## Restoration Steps

### 1. Initial Server Setup
```bash
# Login as root
ssh root@yourserver.com

# Update system
apt update && apt upgrade -y

# Install required packages
apt install -y git docker.io docker-compose curl
```

### 2. Copy Backup Files
```bash
# Copy this backup folder to server
scp -r btcpay-backup-20250916 root@yourserver.com:/root/

# Navigate to backup
cd /root/btcpay-backup-20250916
```

### 3. Install BTCPay Server
```bash
# Clone BTCPay Docker repository
git clone https://github.com/btcpayserver/btcpayserver-docker /opt/btcpayserver-docker
cd /opt/btcpayserver-docker

# Copy environment file
cp /root/btcpay-backup-20250916/.env /opt/.env

# Copy override file
cp /root/btcpay-backup-20250916/docker-compose.override.yml ./

# Update domain in .env if needed
nano /opt/.env
# Change BTCPAY_HOST to your new domain if different
```

### 4. Run BTCPay Setup
```bash
# Load environment
source /opt/.env

# Run setup
./btcpay-setup.sh -i

# This will:
# - Generate docker-compose configuration
# - Create necessary volumes
# - Start all containers
# - Setup SSL certificates
```

### 5. Restore Monero Wallet (if needed)
```bash
# Wait for containers to start
docker ps

# Create wallet password file
docker exec btcpayserver_monero_wallet sh -c 'echo "password" > /wallet/password.txt'

# Restart wallet container
docker restart btcpayserver_monero_wallet

# Verify wallet is running
docker logs btcpayserver_monero_wallet --tail 50
```

### 6. Configure BTCPay Store
1. Access BTCPay at https://yourdomain.com
2. Create admin account
3. Create store
4. Enable Bitcoin and install Monero plugin:
   - Server Settings → Plugins → Install Monero plugin
   - Restart BTCPay after plugin installation
5. Configure Monero wallet in store settings:
   - Wallet Address: Use the address from monero-wallet-info.txt
   - Or generate new wallet if preferred

### 7. Security Hardening
```bash
# Setup firewall
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 2255/tcp  # If using custom SSH port
ufw --force enable

# Change SSH port (optional)
sed -i 's/#Port 22/Port 2255/' /etc/ssh/sshd_config
systemctl restart ssh

# Install fail2ban
apt install -y fail2ban
systemctl enable fail2ban
systemctl start fail2ban
```

### 8. Verify Installation
```bash
# Check all containers running
docker ps

# Check Bitcoin sync status
docker logs generated_bitcoin_1 | grep -i "progress"

# Check Monero status
docker logs btcpayserver_monero | tail -20

# Check BTCPay logs
docker logs generated_btcpayserver_1 | tail -50

# Verify pruning is active
docker logs generated_bitcoin_1 | grep -i "prune"
```

## Important Notes

### Monero Wallet
The Monero wallet address in this backup is:
```
49TnBo2VHbncxvrMFbX5uMS9mtAGkiG1L4N6i7MMz4MhA9AXfyRqBdmf1XrFtGXq2v2G72TNtiVFo2kot5SHnBBz3gwoMj9
```

RPC Password: `password`

### Bitcoin Pruning
Bitcoin is configured to use maximum 10GB disk space. The configuration is in docker-compose.override.yml and will be applied automatically.

### Domain Changes
If restoring to a different domain:
1. Update BTCPAY_HOST in /opt/.env
2. Update REVERSEPROXY_DEFAULT_HOST in /opt/.env
3. Re-run: `./btcpay-setup.sh -i`

### Troubleshooting

**Monero wallet not connecting:**
```bash
docker exec btcpayserver_monero_wallet sh -c 'ls -la /wallet/'
docker restart btcpayserver_monero_wallet
```

**Bitcoin not pruning:**
```bash
# Verify override file is in place
cat /opt/btcpayserver-docker/docker-compose.override.yml

# Restart Bitcoin container
docker restart generated_bitcoin_1
```

**SSL certificate issues:**
```bash
# Force renewal
docker exec generated_letsencrypt-nginx-proxy-companion_1 /app/force_renew
```

## Support
For BTCPay Server support: https://docs.btcpayserver.org/
For Monero plugin: Check BTCPay Server Plugins documentation