feat: Initial commit for OnEver Drive centralized backup system with Windows PyQt6 agent and Proxmox LXC deployment

This commit is contained in:
2026-08-13 19:33:44 -03:00
commit 1bfb808c79
77 changed files with 10675 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# Allow streaming chunk uploads without buffer size limits
client_max_body_size 50M;
upstream backend_upstream {
server backend:8000;
}
server {
listen 80;
server_name _;
# Frontend SPA Static Files
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
# API Reverse Proxy
location /api/ {
proxy_pass http://backend_upstream;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Direct chunk upload streaming
proxy_request_buffering off;
proxy_buffering off;
proxy_read_timeout 300s;
}
# WebSocket Reverse Proxy
location /ws/ {
proxy_pass http://backend_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
}
}
@@ -0,0 +1,95 @@
#!/bin/bash
# ==============================================================================
# OnEver Drive — Proxmox VE Host Provisioning Script
# Executed directly on the Proxmox VE Host Shell (pve)
# Creates native Debian 12 / 13 LXC Container and mounts persistent storage
# ==============================================================================
set -e
# Configuration variables
CT_ID=100
HOSTNAME="onever-backend"
MEMORY=2048
SWAP=1024
CORES=2
DISK_SIZE="20G"
STORAGE_POOL="local-lvm"
HOST_BACKUP_STORAGE="/mnt/pve/backup-pool" # Adjust to your Proxmox ZFS/LVM path
BRIDGE="vmbr0"
IP_CONFIG="dhcp" # Or: "192.168.1.100/24,gw=192.168.1.1"
echo "========================================================================"
echo " ONEVER DRIVE — PROXMOX VE LXC CREATION SCRIPT "
echo "========================================================================"
# 1. Check Proxmox environment
if ! command -v pct &> /dev/null; then
echo "[!] Error: 'pct' command not found. This script must be executed on a Proxmox VE node."
exit 1
fi
# 2. Check if CT ID already exists
if pct status "$CT_ID" &> /dev/null; then
echo "[!] Error: Container ID $CT_ID already exists. Please choose a different CT_ID."
exit 1
fi
# 3. Locate or download Debian 12 / 13 standard template
echo "[*] Searching for Debian 12 / 13 template..."
pveam update
TEMPLATE=$(pveam available | grep -E "debian-(12|13)-standard" | tail -n 1 | awk '{print $2}')
if [ -z "$TEMPLATE" ]; then
echo "[!] Could not automatically find Debian template. Using default debian-12-standard."
TEMPLATE="debian-12-standard_12.2-1_amd64.tar.zst"
fi
if ! pveam list local | grep -q "$TEMPLATE"; then
echo "[*] Downloading template: $TEMPLATE..."
pveam download local "$TEMPLATE"
fi
TEMPLATE_PATH="local:vztmpl/$TEMPLATE"
# 4. Create persistent host directories if not present
echo "[*] Preparing host persistent backup storage at: $HOST_BACKUP_STORAGE..."
mkdir -p "$HOST_BACKUP_STORAGE/backups"
mkdir -p "$HOST_BACKUP_STORAGE/temp"
chmod 775 "$HOST_BACKUP_STORAGE/backups"
chmod 777 "$HOST_BACKUP_STORAGE/temp"
# 5. Create native LXC Container
echo "[*] Creating LXC container CT $CT_ID ($HOSTNAME)..."
pct create "$CT_ID" "$TEMPLATE_PATH" \
--hostname "$HOSTNAME" \
--memory "$MEMORY" \
--swap "$SWAP" \
--cores "$CORES" \
--ostype debian \
--storage "$STORAGE_POOL" \
--rootfs "$STORAGE_POOL:$DISK_SIZE" \
--net0 "name=eth0,bridge=$BRIDGE,ip=$IP_CONFIG" \
--unprivileged 1 \
--onboot 1 \
--start 0
# 6. Mount persistent storage volumes directly to the LXC
echo "[*] Mounting host persistent storage pool into CT $CT_ID..."
pct set "$CT_ID" -mp0 "$HOST_BACKUP_STORAGE/backups,mp=/storage/backups"
pct set "$CT_ID" -mp1 "$HOST_BACKUP_STORAGE/temp,mp=/storage/temp"
# 7. Start container
echo "[*] Starting CT $CT_ID..."
pct start "$CT_ID"
echo ""
echo "========================================================================"
echo "[+] Container CT $CT_ID ($HOSTNAME) successfully created and started!"
echo "========================================================================"
echo ""
echo "Next step: Enter container and run the Debian native installer:"
echo " pct enter $CT_ID"
echo " git clone <REPO_URL> /opt/onever_drive"
echo " bash /opt/onever_drive/deployment/proxmox/02-install-backend-debian.sh"
echo ""
@@ -0,0 +1,188 @@
#!/bin/bash
# ==============================================================================
# OnEver Drive — Debian 12 / 13 Native LXC Setup Script
# Executed inside CT 100 (Debian 12 Bookworm / Debian 13 Trixie)
# ==============================================================================
set -e
APP_DIR="/opt/onever_drive"
WEB_ROOT="/var/www/onever-drive-web"
STORAGE_DIR="/storage/backups"
TEMP_DIR="/storage/temp"
DB_NAME="onever_drive"
DB_USER="onever_user"
DB_PASS="OneverSecurePass2026!"
echo "========================================================================"
echo " ONEVER DRIVE — NATIVE DEBIAN 12/13 LXC INSTALLATION "
echo "========================================================================"
# 1. Update APT and install native dependencies
echo "[1/7] Installing native Debian system packages..."
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends \
postgresql \
postgresql-contrib \
nginx \
python3 \
python3-pip \
python3-venv \
python3-dev \
libpq-dev \
gcc \
curl \
git \
acl \
ufw \
ca-certificates \
gnupg
# Install Node.js (v20+ LTS) if not installed or outdated
if ! command -v node &> /dev/null; then
echo "[*] Installing Node.js LTS for frontend build..."
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get install -y nodejs
fi
# 2. Configure native PostgreSQL
echo "[2/7] Configuring PostgreSQL database..."
systemctl start postgresql
systemctl enable postgresql
sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname = '$DB_NAME'" | grep -q 1 || \
sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;"
sudo -u postgres psql -tc "SELECT 1 FROM pg_roles WHERE rolname = '$DB_USER'" | grep -q 1 || \
sudo -u postgres psql -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_PASS';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
sudo -u postgres psql -d "$DB_NAME" -c "GRANT ALL ON SCHEMA public TO $DB_USER;"
sudo -u postgres psql -d "$DB_NAME" -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO $DB_USER;"
sudo -u postgres psql -d "$DB_NAME" -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO $DB_USER;"
# Ingest DDL schema if tables are not initialized
if [ -f "$APP_DIR/database/schema.sql" ]; then
echo "[*] Ingesting database schema..."
sudo -u postgres psql -d "$DB_NAME" -f "$APP_DIR/database/schema.sql" || true
fi
# 3. Prepare storage directories & permissions
echo "[3/7] Setting up storage directories..."
mkdir -p "$STORAGE_DIR/clients"
mkdir -p "$TEMP_DIR"
chown -R www-data:www-data "$STORAGE_DIR" "$TEMP_DIR"
chmod 775 "$STORAGE_DIR"
chmod 777 "$TEMP_DIR"
# 4. Configure Python virtual environment & backend
echo "[4/7] Setting up Python backend virtual environment..."
python3 -m venv "$APP_DIR/venv"
"$APP_DIR/venv/bin/pip" install --upgrade pip
"$APP_DIR/venv/bin/pip" install -r "$APP_DIR/backend/requirements.txt"
# 5. Build React Web Application
echo "[5/7] Compiling Frontend Web Dashboard..."
if [ -d "$APP_DIR/frontend" ]; then
cd "$APP_DIR/frontend"
npm install
npm run build
mkdir -p "$WEB_ROOT"
cp -r dist/* "$WEB_ROOT/"
chown -R www-data:www-data "$WEB_ROOT"
fi
# 6. Configure Systemd Service for Backend API
echo "[6/7] Configuring systemd service for OnEver Drive Backend..."
cat <<EOF > /etc/systemd/system/onever-backend.service
[Unit]
Description=OnEver Drive Central API Backend
After=network.target postgresql.service
[Service]
Type=simple
User=root
WorkingDirectory=$APP_DIR/backend
Environment="PYTHONPATH=$APP_DIR/backend"
Environment="DATABASE_URL=postgresql+asyncpg://$DB_USER:$DB_PASS@127.0.0.1:5432/$DB_NAME"
Environment="STORAGE_ROOT=$STORAGE_DIR"
Environment="STORAGE_TEMP_ROOT=$TEMP_DIR"
Environment="SECRET_KEY=onever-drive-prod-key-$(openssl rand -hex 16)"
Environment="ENVIRONMENT=production"
Environment="DEBUG=false"
ExecStart=$APP_DIR/venv/bin/uvicorn app.main:app --host 127.0.0.1 --port 8000 --workers 4
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now onever-backend.service
# 7. Configure Nginx Reverse Proxy
echo "[7/7] Configuring Nginx reverse proxy with chunk streaming and WebSockets..."
cat <<'EOF' > /etc/nginx/sites-available/onever-drive
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
# Frontend SPA Web Application
root /var/www/onever-drive-web;
index index.html;
# Allow large / unbounded file chunk streaming
client_max_body_size 0;
location / {
try_files $uri $uri/ /index.html;
}
# Backend REST API
location /api/ {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Disable proxy buffering for direct chunk streaming
proxy_request_buffering off;
proxy_buffering off;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
# WebSockets Telemetry
location /ws/ {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
}
EOF
rm -f /etc/nginx/sites-enabled/default
ln -sf /etc/nginx/sites-available/onever-drive /etc/nginx/sites-enabled/onever-drive
nginx -t
systemctl restart nginx
systemctl enable nginx
echo ""
echo "========================================================================"
echo "[+] OnEver Drive instalado y ejecutándose exitosamente en Debian 12/13!"
echo "========================================================================"
echo "Acceda a la interfaz web en: http://$(hostname -I | awk '{print $1}')"
echo "Credenciales por defecto: admin@oneverdrive.local / Admin1234!"
echo ""
+87
View File
@@ -0,0 +1,87 @@
#!/bin/bash
# ==============================================================================
# OnEver Drive — SSL / HTTPS Configuration for Debian 12 / 13 LXC
# Supports Let's Encrypt (Certbot) or Local High-Entropy Self-Signed Cert
# ==============================================================================
set -e
DOMAIN="$1"
SSL_DIR="/etc/ssl/onever-drive"
if [ -z "$DOMAIN" ]; then
echo "Uso:"
echo " $0 <midominio.com> # Para Certbot / Let's Encrypt"
echo " $0 self-signed # Para certificado autofirmado LAN / Intranet"
exit 1
fi
if [ "$DOMAIN" != "self-signed" ]; then
echo "[*] Instalando Certbot para Let's Encrypt..."
apt-get update && apt-get install -y certbot python3-certbot-nginx
certbot --nginx -d "$DOMAIN" --non-interactive --agree-tos -m "admin@$DOMAIN"
echo "[+] Certificado Let's Encrypt configurado para $DOMAIN"
else
echo "[*] Generando certificado SSL autofirmado de 4096 bits para Intranet..."
mkdir -p "$SSL_DIR"
openssl req -x509 -nodes -days 3650 -newkey rsa:4096 \
-keyout "$SSL_DIR/server.key" \
-out "$SSL_DIR/server.crt" \
-subj "/C=ES/ST=State/L=City/O=OnEver/CN=onever-drive.local"
cat <<'EOF' > /etc/nginx/sites-available/onever-drive
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
ssl_certificate /etc/ssl/onever-drive/server.crt;
ssl_certificate_key /etc/ssl/onever-drive/server.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
root /var/www/onever-drive-web;
index index.html;
client_max_body_size 0;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_request_buffering off;
proxy_buffering off;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
location /ws/ {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
}
EOF
nginx -t
systemctl restart nginx
echo "[+] SSL autofirmado activado en puerto 443 (HTTPS)"
fi
@@ -0,0 +1,25 @@
#!/bin/bash
# ==============================================================================
# OnEver Drive — System Database & Metadata Self-Backup Script
# Backs up PostgreSQL database and configuration to persistent storage
# ==============================================================================
set -e
BACKUP_DEST="/storage/backups/_system_metadata"
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
DB_NAME="onever_drive"
RETENTION_DAYS=30
mkdir -p "$BACKUP_DEST"
echo "[*] Creating database dump for $DB_NAME..."
sudo -u postgres pg_dump "$DB_NAME" | gzip > "$BACKUP_DEST/onever_db_$TIMESTAMP.sql.gz"
echo "[*] Backing up configuration files..."
tar -czf "$BACKUP_DEST/config_$TIMESTAMP.tar.gz" /etc/nginx/sites-available/onever-drive /etc/systemd/system/onever-backend.service 2>/dev/null || true
echo "[*] Pruning old database dumps older than $RETENTION_DAYS days..."
find "$BACKUP_DEST" -type f -name "*.gz" -mtime +$RETENTION_DAYS -delete
echo "[+] Self-backup completed: $BACKUP_DEST/onever_db_$TIMESTAMP.sql.gz"
+64
View File
@@ -0,0 +1,64 @@
#!/bin/bash
# ==============================================================================
# OnEver Drive — Proxmox VE LXC 1: Backend API Provisioning Script
# Target: Debian 12 Bookworm LXC (CT 100)
# ==============================================================================
set -e
echo "=== [1/6] Actualizando paquetes base del sistema Debian 12 ==="
apt-get update && apt-get upgrade -y
apt-get install -y curl git ufw python3 python3-pip python3-venv postgresql postgresql-contrib nginx
echo "=== [2/6] Configurando base de datos PostgreSQL ==="
systemctl start postgresql
systemctl enable postgresql
sudo -u postgres psql -c "CREATE DATABASE onever_drive;" || true
sudo -u postgres psql -c "CREATE USER onever_user WITH ENCRYPTED PASSWORD 'OneverSecurePass2026!';" || true
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE onever_drive TO onever_user;" || true
sudo -u postgres psql -d onever_drive -c "GRANT ALL ON SCHEMA public TO onever_user;" || true
echo "=== [3/6] Preparando directorios de aplicación y almacenamiento ==="
mkdir -p /opt/onever_drive
mkdir -p /storage/backups/clients
mkdir -p /storage/temp
chown -R www-data:www-data /storage
echo "=== [4/6] Configurando entorno virtual de Python ==="
python3 -m venv /opt/onever_drive/venv
/opt/onever_drive/venv/pip install --upgrade pip
# Copiar archivos de backend (asumiendo clonado en /opt/onever_drive)
if [ -f "/opt/onever_drive/backend/requirements.txt" ]; then
/opt/onever_drive/venv/pip install -r /opt/onever_drive/backend/requirements.txt
fi
echo "=== [5/6] Creando servicio systemd para OnEver Drive Backend ==="
cat <<EOF > /etc/systemd/system/onever-backend.service
[Unit]
Description=OnEver Drive Central API Backend
After=network.target postgresql.service
[Service]
User=root
WorkingDirectory=/opt/onever_drive/backend
Environment="DATABASE_URL=postgresql+asyncpg://onever_user:OneverSecurePass2026!@127.0.0.1:5432/onever_drive"
Environment="STORAGE_ROOT=/storage/backups"
Environment="STORAGE_TEMP_ROOT=/storage/temp"
Environment="SECRET_KEY=$(openssl rand -hex 32)"
Environment="ENVIRONMENT=production"
ExecStart=/opt/onever_drive/venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable onever-backend.service
systemctl start onever-backend.service
echo "=== [6/6] Provisionamiento completado exitosamente ==="
echo "El backend de OnEver Drive está activo en http://127.0.0.1:8000"
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# ==============================================================================
# OnEver Drive — Proxmox VE LXC 2: Dedicated Storage Node Setup Script
# Target: Debian 12 Bookworm LXC (CT 101)
# ==============================================================================
set -e
echo "=== [1/4] Configurando nodo de almacenamiento Proxmox VE ==="
apt-get update && apt-get install -y nfs-kernel-server rsync zfsutils-linux acl
echo "=== [2/4] Creando jerarquía de almacenamiento y permisos de aislamiento ==="
mkdir -p /storage/backups/clients
mkdir -p /storage/temp
chmod 750 /storage/backups
chmod 770 /storage/temp
echo "=== [3/4] Configuración de punto de montaje persistente ==="
# En Proxmox Host (pve), montar el dataset ZFS o volumen LVM con:
# pct set 100 -mp0 /mnt/pve/backup-zfs/backups,mp=/storage/backups
cat <<EOF
--------------------------------------------------------------------------------
Para vincular este almacenamiento con el LXC 1 (Backend) en el nodo Proxmox Host:
Ejecute en el shell del nodo Proxmox VE:
pct set 100 -mp0 /storage/backups,mp=/storage/backups
pct set 100 -mp1 /storage/temp,mp=/storage/temp
--------------------------------------------------------------------------------
EOF
echo "=== [4/4] Storage Node configurado correctamente ==="