Estado: produccion inicial endurecida
Fecha: 2026-05-05
Este runbook cubre backup, restore, deploy, rollback, migraciones y checklist E2E para el VPS sa-tools.
Rutas actuales:
/var/www/ops/var/backups/ops-center/etc/ops-center/auth.env/etc/ops-center/db.envops-center.serviceops-dispatch-launcher.serviceops-templates-scheduler.timerhttp://127.0.0.1:3847/apihttps://ops.solucionesabiertas.net/apiAntes de cada deploy:
pg_dump de ops_center.Si una validacion falla, parar y restaurar o corregir antes de seguir.
Local desde el workspace:
ts=$(date +%Y%m%d_%H%M%S)
zip -qr "backups/ops-center-local-$ts.zip" . -x '.git/*' 'node_modules/*' 'backups/*' 'tmp/*'
VPS:
ts=$(date +%Y%m%d_%H%M%S)
backup_dir="/var/backups/ops-center/pre_deploy_$ts"
sudo mkdir -p "$backup_dir"
sudo python3 -m zipfile -c "$backup_dir/ops-source.zip" /var/www/ops
sudo -u postgres pg_dump ops_center | sudo tee "$backup_dir/ops-center.sql" >/dev/null
sudo ls -lah "$backup_dir"
El servidor no es un checkout git. El deploy seguro es copiar artefactos versionados a tmp y luego instalar.
Ejemplo para archivos de app:
ssh sa-tools 'sudo mkdir -p /var/www/ops/tmp/deploy && sudo chown $USER:$USER /var/www/ops/tmp/deploy'
scp server.js public/index.html package.json scripts/smoke-saas-e2e.js sa-tools:/var/www/ops/tmp/deploy/
ssh sa-tools 'set -e;
sudo install -m 0644 /var/www/ops/tmp/deploy/server.js /var/www/ops/server.js;
sudo install -m 0644 /var/www/ops/tmp/deploy/index.html /var/www/ops/public/index.html;
sudo install -m 0644 /var/www/ops/tmp/deploy/package.json /var/www/ops/package.json;
sudo install -m 0755 /var/www/ops/tmp/deploy/smoke-saas-e2e.js /var/www/ops/scripts/smoke-saas-e2e.js;
sudo systemctl restart ops-center.service;
sudo systemctl restart ops-dispatch-launcher.service'
Si cambia package-lock.json o dependencias:
cd /var/www/ops
npm ci --omit=dev
Normal:
cd /var/www/ops
set -a
. /etc/ops-center/db.env
set +a
npm run db:migrate
Migraciones con DDL/FK si el rol app no tiene permisos suficientes:
sudo -u postgres psql -d ops_center -f migrations/NNN-name.sql
Despues insertar registro en schema_migrations solo si el runner no pudo hacerlo y el SQL ya se aplico correctamente.
Entorno:
cd /var/www/ops
set -a
. /etc/ops-center/auth.env
. /etc/ops-center/db.env
set +a
Health:
curl -fsS -H "X-OPS-Service-Token: $OPS_SERVICE_TOKEN" \
http://127.0.0.1:3847/api/system/health
Dispatch:
curl -fsS -H "X-OPS-Service-Token: $OPS_SERVICE_TOKEN" \
http://127.0.0.1:3847/api/dispatch/health
npm run smoke:dispatch
SaaS onboarding:
npm run smoke:saas
Readiness:
curl -fsS -H "X-OPS-Service-Token: $OPS_SERVICE_TOKEN" \
http://127.0.0.1:3847/api/saas/readiness
Servicios:
systemctl is-active ops-center.service ops-dispatch-launcher.service ops-templates-scheduler.timer
Restaurar fuentes:
sudo systemctl stop ops-dispatch-launcher.service
sudo systemctl stop ops-center.service
sudo unzip -oq /var/backups/ops-center/<backup>/ops-source.zip -d /
sudo systemctl start ops-center.service
sudo systemctl start ops-dispatch-launcher.service
Restaurar DB solo si es imprescindible:
sudo systemctl stop ops-dispatch-launcher.service
sudo systemctl stop ops-center.service
sudo -u postgres dropdb ops_center
sudo -u postgres createdb ops_center
sudo -u postgres psql -d ops_center -f /var/backups/ops-center/<backup>/ops-center.sql
sudo systemctl start ops-center.service
sudo systemctl start ops-dispatch-launcher.service
Despues ejecutar validacion obligatoria completa.
Estado actual:
opencode: operativo.codex: operativo.hermes: operativo con AGENT_CMD_HERMES=/opt/hermes-agent/.venv/bin/hermes en /etc/ops-center/auth.env.claudecode: inactivo hasta configurar ANTHROPIC_API_KEY o claude auth login.Para reactivar claudecode:
npm run worker:doctor.ops-dispatch-launcher.service./api/dispatch/health.Un deploy queda cerrado solo si:
git status --short local esta limpio./api/system/health devuelve ok=true./api/dispatch/health devuelve ok=true./api/saas/readiness devuelve ok=true.npm run smoke:dispatch pasa.npm run smoke:saas pasa.active.