Skip to main content

Overview

Nightshift uses SQLite. The database is a single file at /opt/nightshift/nightshift.db.

Database schema

TableContents
agentsid, tenant_id, name, source_filename, function_name, config_json, storage_path, created_at, updated_at. UNIQUE on (tenant_id, name).
runsid, agent_id, tenant_id, prompt, status (started/completed/error), created_at, completed_at, error.
api_keyskey_hash (SHA-256, primary key), tenant_id, label, created_at.

Database backup

Safe while the server is running:
sudo sqlite3 /opt/nightshift/nightshift.db \
  ".backup /opt/nightshift/backups/nightshift-$(date +%Y%m%d-%H%M%S).db"
Do NOT cp the file while the server is running, SQLite may have uncommitted WAL data. Always use sqlite3 .backup or stop the server first.

Agent file backup

Source code is stored on disk, not in the database:
sudo tar czf /opt/nightshift/backups/agents-$(date +%Y%m%d).tar.gz \
  -C /opt/nightshift agents/

Restore from backup

1

Stop the server

Stop the running Nightshift server process.
2

Restore database

sudo cp /opt/nightshift/backups/nightshift-20260220.db /opt/nightshift/nightshift.db
3

Restart the server

sudo nightshift serve