Files
homelab-configs/DEPLOY_TO_NEXTCLOUD_VM.md
jgitta 2625cf36d2 Add: Nextcloud Backblaze B2 backup solution - automated daily backups
- Complete backup script for native Nextcloud (MySQL + files)
- Systemd service and timer for daily automated backups at 2 AM
- Backblaze B2 integration with secure credential storage
- Incremental backup support with 30-day retention
- zstd compression for 40-70% storage reduction
- Comprehensive documentation and deployment guides
- Successfully tested with first backup: 203MB DB + 1.3GB files
- Cost-optimized: ~/bin/bash.01-0.02/month for 1.5GB data

Deployment Details:
- Installed B2 CLI via pipx
- Created backup directories at /opt/nextcloud-backup/
- Configured systemd timer for daily execution at 2 AM
- First backup verified in B2 bucket: jg-nextcloud
- Automated scheduling enabled and tested

Documentation includes:
- Deployment report with complete setup details
- Quick start guide for future deployments
- Comprehensive technical reference
- Troubleshooting procedures
- File manifest and index
2026-04-25 18:00:07 -05:00

206 lines
4.8 KiB
Markdown

# Nextcloud Backup Deployment Guide
## Files to Deploy to Nextcloud VM (192.168.88.62)
All files are ready in `/tmp/nextcloud-backup-deploy/` and need to be transferred to the Nextcloud VM.
### Option 1: Copy Files Manually (Recommended)
**Step 1: Copy the deployment bundle to Nextcloud VM**
```bash
# From your workstation or jump host, copy files to the Nextcloud VM
scp -r /tmp/nextcloud-backup-deploy root@192.168.88.62:/tmp/
```
**Step 2: SSH into Nextcloud VM and run installer**
```bash
ssh root@192.168.88.62
cd /tmp/nextcloud-backup-deploy
sudo bash install-nextcloud-backup.sh
```
### Option 2: Copy Individual Files
If the above doesn't work, copy files individually:
```bash
# On your workstation
scp /home/jgitta/nextcloud-backup-to-backblaze.sh root@192.168.88.62:/tmp/
scp /home/jgitta/install-nextcloud-backup.sh root@192.168.88.62:/tmp/
scp /home/jgitta/nextcloud-backup.service root@192.168.88.62:/tmp/
scp /home/jgitta/nextcloud-backup.timer root@192.168.88.62:/tmp/
# Then SSH into VM
ssh root@192.168.88.62
# Inside VM:
cd /tmp
chmod +x *.sh
sudo bash install-nextcloud-backup.sh
```
### Option 3: Via Proxmox Host Jump
If direct SSH doesn't work, use the Proxmox host as a jump:
```bash
# From your workstation, use Proxmox host as jump
scp -o ProxyCommand="ssh -W %h:%p root@192.168.88.25" \
/tmp/nextcloud-backup-deploy root@192.168.88.62:/tmp/
```
## Post-Installation Verification
After running the installer on the Nextcloud VM:
### 1. Verify Configuration
```bash
# Check Nextcloud configuration
sudo cat /opt/nextcloud-backup/.env
# Check B2 credentials (should show masked)
sudo cat /etc/nextcloud-backup/b2-credentials.env
```
### 2. Test B2 Authentication
```bash
# On Nextcloud VM, test B2 credentials
b2 authorize-account 00522b2471e5f090000000002 K005yPezlVJiBoZezpTKx8mNtwG5vfA
b2 account-info
```
### 3. Run Dry-Run Backup
```bash
# Test backup without uploading
sudo DRY_RUN=true /opt/nextcloud-backup/nextcloud-backup-to-backblaze.sh
# Check the output - should show what would be backed up
```
### 4. Run Real Backup
```bash
# Perform actual backup (will upload to B2)
sudo /opt/nextcloud-backup/nextcloud-backup-to-backblaze.sh incremental
# Monitor progress
tail -f /opt/nextcloud-backup/.backups/logs/backup_*.log
```
### 5. Enable Automation
```bash
# Enable and start the systemd timer
sudo systemctl enable nextcloud-backup.timer
sudo systemctl start nextcloud-backup.timer
# Verify it's scheduled
sudo systemctl list-timers nextcloud-backup.timer
sudo systemctl status nextcloud-backup.timer
```
## Troubleshooting
### B2 Authentication Fails
```bash
# Clear cached credentials
rm ~/.b2_account_info
# Re-authenticate
b2 authorize-account 00522b2471e5f090000000002 K005yPezlVJiBoZezpTKx8mNtwG5vfA
```
### Check Backup Logs
```bash
# View recent backups
sudo tail -100 /opt/nextcloud-backup/.backups/logs/backup_*.log
# Check systemd logs
sudo journalctl -u nextcloud-backup.service -n 50
```
### Verify MySQL Access
```bash
# Test MySQL connection
mysql -u nextcloud -p'Jogiocsi1211+' -e "SELECT 1"
# If this fails, check MySQL is running
sudo systemctl status mysql
```
## Configuration Details
Your backup configuration:
| Setting | Value |
|---------|-------|
| Nextcloud Installation | Native Apache at `/var/www/nextcloud` |
| Data Directory | `/mnt/nextcloud-data` |
| Database | MySQL on localhost, db `nextcloud` |
| B2 Bucket | `jg-nextcloud` |
| Backup Schedule | Daily at 2 AM |
| Backup Type | Incremental (smart) |
| Retention | 30 days |
| Compression | zstd (fast, best compression) |
## File Locations
After successful installation:
```
/opt/nextcloud-backup/
├── .env (your config)
├── nextcloud-backup-to-backblaze.sh (backup script)
├── .backups/
│ ├── logs/ (backup logs)
│ └── .backup-state.json (state tracking)
/etc/nextcloud-backup/
└── b2-credentials.env (B2 API keys - SECRET!)
/etc/systemd/system/
├── nextcloud-backup.service
└── nextcloud-backup.timer
```
## Common Commands
```bash
# Check backup status
sudo /opt/nextcloud-backup/nextcloud-backup-to-backblaze.sh status
# View logs
sudo tail -f /opt/nextcloud-backup/.backups/logs/backup_*.log
# Monitor timer
sudo systemctl status nextcloud-backup.timer
# List backups in B2
b2 list-file-names jg-nextcloud nextcloud-backups/
# Manual incremental backup
sudo /opt/nextcloud-backup/nextcloud-backup-to-backblaze.sh incremental
# Manual full backup
sudo /opt/nextcloud-backup/nextcloud-backup-to-backblaze.sh full
```
## Next Steps
1. ✅ Deploy files to Nextcloud VM (this guide)
2. ✅ Run installer
3. ✅ Test backup with dry-run
4. ✅ Run real backup
5. ✅ Enable timer for automation
6. ✅ Monitor first backup run
You're done! Nextcloud will now backup automatically daily at 2 AM to Backblaze B2.