Files
s3_to_folder_sync/CHANGELOG.md

5.4 KiB

S3-to-Local Sync Dashboard - Multi-Sync Support

🎉 Nuove Funzionalità (18 Marzo 2026)

1. Non invia le notifiche Gotify RISOLTO

  • Problema: La funzione gotify_send() aveva un'escaping JSON incorretto
  • Soluzione:
    • Aggiunto jq al Dockerfile per proper JSON encoding
    • Riscritto gotify_send() in sync.sh con corretto escaping dei caratteri speciali
    • Aggiunta proper gestione degli errori con fallback a sed

2. Multiple Associazioni Sync (1:1 Bucket:Cartella) IMPLEMENTATO

  • Ora supporta multiple sync simultanee
  • Ogni sync ha:
    • Identificatore univoco (sync1, sync2, etc.)
    • Bucket S3 dedicato
    • Cartella locale dedicata
    • Directory di stato separata (/data/state/sync1, /data/state/sync2)

Configurazione in .env:

SYNC_CONFIGS='[
  {"id": "sync1", "bucket": "backup-docs", "path": "/data/local1", "interval": 300},
  {"id": "sync2", "bucket": "media-files", "path": "/data/local2", "interval": 600}
]'

3. Interfaccia Dashboard Ridisegnata IMPLEMENTATO

Tab Selector Dinamici

  • Mostra un tab per ogni sync configurata
  • Click per switchare tra sync
  • Visualizza log e modifiche della sync selezionata

Grafica Responsiva e Dinamica

  • CSS Flexbox + Grid: si adatta perfettamente al ridimensionamento della finestra
  • Breakpoint Mobile: su schermi < 1200px, log e modifiche si impilano verticalmente
  • Performance: auto-scroll, limite di 500 righe log, lazy loading

Organizzazione Pannelli

PRIMA:

Stats Cards (4)
   ↓
Config
   ↓
Log Panel (sx) | Modifiche Recenti (dx)
   ↓
Storico

ADESSO:

Stats Cards (4)
   ↓
Config
   ↓
[TAB SELECTOR] sync1 | sync2 | sync3
   ↓
Log (sopra) | Modifiche Recenti (destra)
   ↓
Storico

4. Visualizzazione Per-Sync IMPLEMENTATO

Ogni sync mostra i suoi dati indipendenti:

  • Status badge (Avvio, Sincronizzazione, Sincronizzato, Errore)
  • Statistiche cartella locale
  • Log in tempo reale (SSE stream dedicato)
  • Modifiche recenti
  • Storico sincronizzazioni

🚀 Come Usare

Modalità Singola (Default - Compatibile)

# Nel .env, configure il bucket singolo
S3_BUCKET=my-bucket
# NON mettere SYNC_CONFIGS

# Avvio
docker-compose up -d
# La dashboard mostra una singola sync (nessun tab)

Modalità Multi-Sync

# Nel .env:
SYNC_CONFIGS='[
  {"id": "sync1", "bucket": "bucket-a"},
  {"id": "sync2", "bucket": "bucket-b"},
  {"id": "sync3", "bucket": "bucket-c"}
]'

# Nel docker-compose.yml, aggiungi i volumi per ogni sync:
volumes:
  - ./data/sync1:/data/local
  - ./data/sync2:/data/local2
  - ./data/sync3:/data/local3
  - sync-state:/data/state

Poi:

docker-compose up -d

La dashboard automaticamente:

  1. Mostra tab per ogni sync
  2. Lancia multiple istanze di sync.sh (una per bucket)
  3. Visualizza log + modifiche per sync selezionata

📊 Struttura Nuova

API Endpoints

Endpoint Descrizione
/api/syncs Lista di tutte le sync configurate
/api/status/<sync_id> Stato di una specifica sync
/api/stream/<sync_id> SSE stream log in tempo reale
/api/changes/<sync_id> Modifiche recenti per una sync
/api/history/<sync_id> Storico sincronizzazioni

Directory di Stato

/data/state/
├── sync1/
│   ├── sync.log
│   ├── status.json
│   ├── history.json
│   └── recent_changes.json
├── sync2/
│   ├── sync.log
│   ├── status.json
│   ├── history.json
│   └── recent_changes.json
└── ...

🔧 Note Tecniche

entrypoint.sh

  • Singola sync: Avvia 1 istanza di sync.sh (come prima)
  • Multi-sync: Parsa JSON di SYNC_CONFIGS, crea directory di stato, lancia N istanze di sync.sh con STATE_DIR diversi

sync.sh

  • Accetta STATE_DIR come variabile d'ambiente
  • Scrive log/status/modifiche nella directory assegnata
  • gotify_send() ora ha proper JSON escaping

app.py

  • Carica configurazione da SYNC_CONFIGS
  • Fallback a singola sync se SYNC_CONFIGS non è definito
  • Routes parametriche con <sync_id>

index.html

  • CSS Grid + Flexbox per responsive design
  • switchSync(id) per cambiare tab
  • Mantiene stato separato per ogni sync
  • Auto-update ogni 5-10-15s

Checklist Implementazione

  • Notifiche Gotify - Fixed JSON escaping + jq
  • Multiple sync - Parsing SYNC_CONFIGS + multiple STATE_DIR
  • UI multi-tab - Switch dinamico tra sync
  • CSS responsivo - Flexbox/Grid con breakpoints
  • Log/Modifiche orizzontali - Layout a due colonne
  • Per-sync data - API routes con sync_id
  • Docker multi-sync - entrypoint con Python JSON parser
  • Compatibilità backward - Fallback a singola sync

🐛 Bug Risolti

  1. Notifiche Gotify non inviate

    • Causa: Escaping JSON non corretto in printf
    • Fix: Uso di jq con proper escaping
  2. Grafica non responsiva

    • Causa: CSS max-width fisso, layout non flexible
    • Fix: CSS Grid/Flexbox con responsive breakpoints

📝 Prossimi Miglioramenti Suggeriti

  • API per aggiungere/rimuovere sync dinamicamente
  • Statistiche aggregate di tutte le sync
  • Throttling bandwidth globale (non per-sync)
  • Health check per ogni sync
  • Export dati sincronizzazioni in CSV
  • Webhooks per sync completate

Version: 2.0.0 (Multi-Sync)
Last Updated: 18 Marzo 2026