# SQLite clone Job for swarm-alpha # Creates a snapshot of the prod neuron.db into swarm-alpha's PVC. # This Job is created by swarm.sh at session start; it is NOT static. # This file is the template — swarm.sh applies it via kubectl after substituting SESSION_ID. # # The Job mounts both the prod PVC (read-only) and the variant PVC (read-write). # It uses a simple cp to snapshot the database before the variant MCP starts. # # NOTE: The prod MCP must be scaled down to 0 OR the Job must use SQLite's backup API # (via sqlite3 .backup command) to ensure consistency. swarm.sh handles the hot-backup # approach using the sqlite3 CLI, so the prod pod does NOT need to stop. apiVersion: batch/v1 kind: Job metadata: name: sqlite-clone-alpha namespace: swarm-alpha labels: app: swarm-clone variant: alpha spec: ttlSecondsAfterFinished: 3600 backoffLimit: 3 template: metadata: labels: app: swarm-clone variant: alpha spec: restartPolicy: OnFailure securityContext: runAsNonRoot: false # sqlite3 needs to run as root to access both PVCs containers: - name: sqlite-clone image: keinos/sqlite3:latest command: - sh - -c - | set -e echo "Starting SQLite hot-backup from prod to swarm-alpha..." # Use SQLite's .backup command for a consistent online backup sqlite3 /prod-data/neuron.db ".backup /variant-data/neuron.db" echo "Backup complete. Verifying..." sqlite3 /variant-data/neuron.db "PRAGMA integrity_check;" echo "SQLite clone complete for swarm-alpha." volumeMounts: - name: prod-data mountPath: /prod-data readOnly: true - name: variant-data mountPath: /variant-data resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 512Mi volumes: - name: prod-data persistentVolumeClaim: claimName: neuron-prod-data readOnly: true - name: variant-data persistentVolumeClaim: claimName: swarm-alpha-data