# PBS Avancado - Funcionalidades e Troubleshooting

## Monitoring e Maintenance

### Verificar Deduplicacao
```bash
# Ver estatisticas datastore
proxmox-backup-manager datastore status main-store

# Ratio deduplicacao (tipico 1.3-2.5x)
```

### Garbage Collection
```bash
# Liberar espaco de backups removidos (retention)
proxmox-backup-manager garbage-collection start main-store

# Agendar GC semanal (Domingo 02:00)
# Via Web UI: Datastore -> main-store -> Prune & GC
```

### Verificar Disk Usage
```bash
df -h /mnt/pbs-datastore

# ZFS
zfs list -o name,used,available,refer rpool/pbs-datastore
```

### Alertas Email
```bash
# Configurar notificacoes
# Via Web UI: Configuration -> Notifications
# SMTP server: mail.descomplicar.pt
# Alertas: disk usage >80%, backup failures
```

## PBS Advanced Features

### Verification Jobs
```bash
# Verificar integridade backups
proxmox-backup-manager verify-job create verify-main \
  --store main-store \
  --schedule "0 4 * * 0"  # Domingo 04:00
```

### Namespace Organization
```bash
# Organizar backups por tipo
proxmox-backup-manager namespace create main-store/production
proxmox-backup-manager namespace create main-store/testing
proxmox-backup-manager namespace create main-store/archived
```

### Tape Backup (futuro)
- PBS suporta LTO tape
- Para compliance de longo prazo
- Cold storage

## Troubleshooting

### Backup failing: "no space"
```bash
# Verificar disk usage
df -h /mnt/pbs-datastore

# Run GC manual
proxmox-backup-manager garbage-collection start main-store

# Ajustar retention (reduzir keeps)
proxmox-backup-manager datastore update main-store --keep-daily 5
```

### Remote sync not working
```bash
# Verificar conectividade
ping <remote-pbs-ip>

# Testar autenticacao
curl -k https://<remote-pbs-ip>:8007/api2/json/access/ticket \
  -d "username=pve-backup@pbs&password=<password>"

# Logs
journalctl -u proxmox-backup -f
```

### Dedup ratio baixo (<1.2x)
```bash
# Verificar se VMs tem dados compressiveis
# VMs com random data (encrypted) nao deduplica bem

# Verificar chunk size (padrao 4MB adequado)
proxmox-backup-manager datastore show main-store
```

## Estrategia 3-2-1 Backup

**Implementacao para Cluster Descomplicar:**

**3 copias:**
1. **Original:** VMs em Node A (producao)
2. **Backup primario:** PBS Node B (16TB HDD)
3. **Backup secundario:** PBS Node A remote sync (12TB HDD)

**2 medias diferentes:**
1. NVMe (VMs producao)
2. HDD Enterprise (PBS datastores)

**1 off-site:**
- **Opcao A:** Hetzner Storage Box (rsync daily)
- **Opcao B:** S3-compatible (Wasabi/Backblaze)
- **Opcao C:** PBS em VPS externo

**RPO:** 1h (backups hourly se critical)
**RTO:** 2-4h (restore + validacao)

## Metricas Esperadas

| Metrica | Valor tipico |
|---------|-------------|
| Dedup ratio | 1.5-2.5x |
| Compression ratio | 1.3-1.8x |
| Backup speed | 100-300 MB/s |
| Restore RTO | 2-4h (para VM 100GB) |
