Applicazione web professionale per la sincronizzazione multi-cloud di storage utilizzando rclone come backend. Supporta interfaccia web intuitiva e API REST complete per automazione.
- β¨ Features
- π Requisiti
- β‘ Quick Start
- π Struttura Progetto
- π₯ Manuale Utente
- π» Manuale Sviluppatore
- π API Reference
- π Use Cases
- π§ Troubleshooting
- π€ Contributi
- Design responsive ottimizzato per desktop e mobile
- Real-time monitoring dei job di sincronizzazione
- Gestione credenziali sicura per diversi provider
- Upload file JSON drag-and-drop per Service Account
- Console output live con streaming log
- Google Cloud Storage (GCS): HMAC + Service Account
- Elastic Cloud Storage (ECS): S3-compatible
- Amazon S3: Standard e compatibili
- MinIO: Self-hosted storage
- Cloudflare R2: Edge storage
- HMAC: Access Key + Secret Key
- Service Account: File JSON o testo (GCS)
- Project Number: Supporto automatico per GCS
- Environment isolation: Credenziali sicure per job
- Job management: Creazione, monitoring, listing
- Server-Sent Events: Stream real-time dei log
- JSON API: Integrabile in workflow esistenti
- Automazione: Supporto completo per scripting
- Python: 3.6 o superiore
- rclone: 1.50+ installato e configurabile
- OS: Linux, macOS, Windows (WSL supportato)
flask>=2.0.0
python-dotenv>=0.19.0
flask-talismangit clone https://github.com/axxx75/s3cp.git
cd s3cp
pip install -U pip
python3 -m venv venv
source venv/bin/activate
pip install flask python-dotenv gunicorn flask-talisman# Installa rclone se non presente
curl https://rclone.org/install.sh | bash
# Verifica installazione
rclone versioncp s3cputo-webapp.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable s3cputo-webapp
systemctl start s3cputo-webapp
# Se vuoi il server in HTTPS scommenta le 2 righe nel file gunicorn.conf.py
Documentati bene su come farlo seriamente, eventualmente con una CA. Al volo puoi fare come segue, crea i file server.crt e server.key nella dir dell'app
openssl req -x509 -newkey rsa:4096 -nodes -keyout server.key -out server.crt -days 365 -subj "/CN=localhost"
# Verifica start
journalctl -u s3cputo-webapp.service -fπ http://localhost:8080
s3cputo/
βββ π start.sh # π§ Script per start application
βββ π gunicorn.conf.py # π§ File conf server gunicorn
βββ π s3cputo-webapp.service # π§ Script for service configuration
βββ π README.md # π Questo file
βββ π app/ # π Folder Application
β βββ π static/ # π Folder static content
β βββ π custom.css # π¨ Styling dell'interfaccia web
β βββ π templates/ # π Folder template html
β βββ π index.html # π Single-page application UI
| βββ π app.py # π§ Main Flask application
| βββ π config.py # βοΈ Provider configurations & flags
| File | Scopo | Descrizione |
|---|---|---|
app.py |
π§ Backend | Flask app, API endpoints, job management |
config.py |
βοΈ Configurazione | Provider configs, rclone flags, paths |
index.html |
π Frontend | SPA con JavaScript per UI interattiva |
custom.css |
π¨ Styling | Design moderno con glassmorphism |
- Seleziona Provider: GCS, ECS, S3, etc.
- Inserisci Credenziali:
- HMAC: Access Key + Secret Key
- Service Account (solo GCS): Upload JSON o incolla testo
- Carica Bucket: Click su "Lista Bucket" per caricare bucket disponibili
- Seleziona Bucket e opzionalmente un Path
- Stessa procedura del source
- PuΓ² essere provider diverso (es. GCS β ECS)
Espandi la sezione "βοΈ Opzioni Avanzate" per:
- Dry Run: Simula sincronizzazione senza trasferire file
- Verbose: Log dettagliati
- Progress: Mostra progresso trasferimento
- Fast List: Ottimizzazione per bucket grandi
- Custom flags: Aggiungi flag rclone personalizzati
- Click "π Avvia Sincronizzazione"
- Monitoring Real-time: I log appaiono automaticamente nella console
- Completion: Messaggio di completamento automatico
Access Key: AKIA1234567890
Secret Key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- File Upload: Drag & drop del file
.json - Text Input: Copia/incolla del contenuto JSON
- Project Number: Inserimento manualenprojectid (required)
graph TD
A[Web UI] --> B[Flask App]
B --> C[rclone CLI]
B --> D[Job Manager]
D --> E[Log Files]
F[REST API] --> B
B --> G[SSE Stream]
list_buckets(): Eseguerclone lsdper elencare bucketcopy(): Lanciarclone syncin background con job IDstream_log(): Server-Sent Events per streaming log real-timejobs(): Lista tutti i job attivi/completati
# Job ID formato: YYYYMMDD_HHMMSS_randomstring
job_id = "{}_{}".format(timestamp, uuid.uuid4().hex[:6])
# Log file: /tmp/job_{job_id}.log
log_file = os.path.join(LOG_DIR, "job_{}.log".format(job_id))def safe_env():
"""Crea environment isolato per rclone subprocess"""
env = os.environ.copy()
# Remove existing rclone env vars
# Add job-specific credentials
return envPROVIDERS = {
"gcs": "Google Cloud Storage",
"ecs": "Elastic Cloud Storage",
"s3": "Amazon S3"
}def get_provider_flags(provider):
"""Ritorna flag specifici per provider"""
flags = GLOBAL_FLAGS.copy()
if provider.lower() == 'gcs':
flags.extend(['--gcs-bucket-policy-only'])
return flags- Single Page Application (SPA)
- Vanilla JavaScript (no frameworks)
- Event-driven UI updates
- CSS Grid + Flexbox layout
// Provider change handler
function handleProviderChange(type) { /* ... */ }
// Credential validation
function getCredentials(type) { /* ... */ }
// Real-time log streaming
const eventSource = new EventSource('/api/log/' + jobId);| Method | Endpoint | Descrizione |
|---|---|---|
POST |
/api/list_buckets |
Lista bucket di un provider |
POST |
/api/copy |
Avvia job di sincronizzazione |
GET |
/api/log/<job_id> |
Stream real-time log job (SSE) |
GET |
/api/jobs |
Lista tutti i job |
Request:
curl -X POST http://localhost:8081/api/list_buckets \
-H "Content-Type: application/json" \
-d '{
"provider": "gcs",
"creds": {
"sa_credentials": "{\"type\":\"service_account\",\"project_id\":\"my-project\",...}",
"gcs_project_number": "123456789"
}
}'Response:
{
"buckets": [
"my-production-bucket",
"my-staging-bucket",
"my-backup-bucket"
]
}Request:
curl -X POST http://localhost:8081/api/copy \
-H "Content-Type: application/json" \
-d '{
"src_provider": "gcs",
"dst_provider": "ecs",
"src_bucket": "source-bucket",
"dst_bucket": "destination-bucket",
"src_path": "data/2025/",
"dst_path": "backup/gcs-migration/",
"src_creds": {
"auth_method": "sa",
"sa_credentials": "{...}",
"gcs_project_number": "123456789"
},
"dst_creds": {
"access_key": "AKIA...",
"secret_key": "wJal..."
},
"additional_flags": ["--verbose", "--progress", "--dry-run"]
}'Response:
{
"job_id": "20251013_232320_a7f3d2"
}Request:
curl -N http://localhost:8081/api/log/20251013_232320_a7f3d2Response (Server-Sent Events):
data: [2025-10-13 23:23:20] Avvio sincronizzazione GCS β ECS
data: [2025-10-13 23:23:21] Validazione credenziali GCS...
data: [2025-10-13 23:23:22] Connessione a ECS stabilita
data: [2025-10-13 23:23:23] Scansione source: data/2025/ (1,247 file, 2.3GB)
data: [2025-10-13 23:23:45] Progresso: 45% (1.03GB trasferiti)
data: [2025-10-13 23:24:12] Progresso: 100% (2.3GB trasferiti)
data: [2025-10-13 23:24:13] β
Sincronizzazione completata con successo
data: [STREAM_END]
Request:
curl http://localhost:8081/api/jobsResponse:
{
"active_jobs": [
"20251013_232320_a7f3d2",
"20251013_231155_b9e4c8",
"20251013_225430_f1a7d9"
],
"total_jobs": 3
}# 1. Verifica bucket source
curl -X POST http://localhost:8081/api/list_buckets \
-H "Content-Type: application/json" \
-d '{
"provider": "gcs",
"creds": {"sa_credentials": "...", "gcs_project_number": "..."}
}'
# 2. Dry run per validare
curl -X POST http://localhost:8081/api/copy \
-H "Content-Type: application/json" \
-d '{
"src_provider": "gcs",
"dst_provider": "ecs",
"src_bucket": "prod-data-gcs",
"dst_bucket": "prod-data-ecs",
"src_creds": {...},
"dst_creds": {...},
"additional_flags": ["--dry-run", "--verbose"]
}'
# 3. Migrazione effettiva
curl -X POST http://localhost:8081/api/copy \
-H "Content-Type: application/json" \
-d '{...}' # Senza --dry-run#!/usr/bin/env python3
import requests
import json
import time
from datetime import datetime
API_BASE = "http://localhost:8081/api"
BACKUP_CONFIG = {
"src_provider": "s3",
"dst_provider": "gcs",
"src_bucket": "production-data",
"dst_bucket": "daily-backups",
"dst_path": f"backup/{datetime.now().strftime('%Y-%m-%d')}/",
"src_creds": {"access_key": "...", "secret_key": "..."},
"dst_creds": {"sa_credentials": "...", "gcs_project_number": "..."},
"additional_flags": ["--verbose", "--progress"]
}
def start_backup():
"""Avvia backup giornaliero"""
response = requests.post(f"{API_BASE}/copy", json=BACKUP_CONFIG)
job_id = response.json()["job_id"]
print(f"β
Backup avviato: {job_id}")
return job_id
def monitor_job(job_id):
"""Monitora job fino a completamento"""
with requests.get(f"{API_BASE}/log/{job_id}", stream=True) as r:
for line in r.iter_lines():
if line:
log_line = line.decode('utf-8').replace('data: ', '')
if log_line == '[STREAM_END]':
print("β
Backup completato!")
break
print(f"π {log_line}")
if __name__ == "__main__":
job_id = start_backup()
monitor_job(job_id)#!/bin/bash
# sync-multi-target.sh
API_BASE="http://localhost:8081/api"
SOURCE_CONFIG='{
"provider": "s3",
"creds": {"access_key": "...", "secret_key": "..."}
}'
# Configurazioni target
declare -A TARGETS=(
["backup-gcs"]='{"provider":"gcs","bucket":"backup-primary"}'
["backup-ecs"]='{"provider":"ecs","bucket":"backup-secondary"}'
["archive-r2"]='{"provider":"r2","bucket":"archive-longterm"}'
)
declare -a JOB_IDS=()
echo "π Avvio sincronizzazione multi-target..."
# Avvia job paralleli
for target_name in "${!TARGETS[@]}"; do
echo "π‘ Avvio sync verso: $target_name"
job_response=$(curl -s -X POST "$API_BASE/copy" \
-H "Content-Type: application/json" \
-d '{
"src_provider": "s3",
"dst_provider": "gcs",
"src_bucket": "production-data",
"dst_bucket": "'$target_name'",
"src_creds": {"access_key": "...", "secret_key": "..."},
"dst_creds": {"sa_credentials": "..."},
"additional_flags": ["--verbose"]
}')
job_id=$(echo "$job_response" | jq -r '.job_id')
JOB_IDS+=("$job_id")
echo "β
Job avviato: $job_id"
done
echo "β³ Monitoraggio job paralleli..."
# Qui puoi aggiungere logica di monitoraggio parallelo# Installa rclone
curl https://rclone.org/install.sh | bash
# Verifica PATH
echo $PATH
which rclone# Valida JSON
cat service-account.json | jq '.'
# Verifica permessi GCS
gcloud auth activate-service-account --key-file=service-account.json
gsutil ls gs://# Verifica permessi directory
ls -la /tmp/
mkdir -p /tmp && chmod 755 /tmp
# Controlla log applicazione
tail -f /tmp/flask_app.log# Test manuale rclone
rclone lsd gcs: -vv
# Verifica credenziali
rclone config show# Export log level
export FLASK_ENV=development
export RCLONE_LOG_LEVEL=DEBUG
# Avvia con log verbose
python app.py --debug# Health check
curl http://localhost:8081/
# Test job listing
curl http://localhost:8081/api/jobs
# Verifica log specifico
curl http://localhost:8081/api/log/JOB_ID# Directory log
ls -la /tmp/job_*.log
# Real-time monitoring
tail -f /tmp/job_20251013_232320_a7f3d2.log
# Cerca errori
grep -i error /tmp/job_*.log
grep -i "failed\|exception" /tmp/job_*.log# Flask app log
tail -f /tmp/flask_app.log
# Filtra per livello
grep "ERROR\|CRITICAL" /tmp/flask_app.log- Docker support per deployment facile
- Authentication utente con login/logout
- Scheduled jobs con cron integration
- Metrics & monitoring con Prometheus
- Multi-language support (EN/IT)
- Backup retention policies automatiche
MIT License - Vedi LICENSE file per dettagli.
- Issues: GitHub Issues
- Documentation: Wiki
Sviluppato con β€οΈ da Axxx e MiniMax Agent
Sincronizzazione cloud sicura e affidabile per i tuoi dati