Back to Litestream

CLI JSON Output

docs/CLI_JSON_OUTPUT.md

0.5.125.4 KB
Original Source

CLI JSON Output

Litestream commands that accept -json write a JSON document to stdout. Errors are written to stderr by the top-level command handler and return a non-zero exit status.

The fields below are the stable output contract for CLI consumers. New fields may be added in future releases, so consumers should ignore unknown fields.

Runtime commands use status values that name the completed state. When a command is already in its requested state, the status uses already_<state>, such as already_registered, already_running, already_stopped, or already_unregistered.

litestream databases -json

Outputs an array of databases loaded from the configuration file.

json
[
  {
    "path": "/var/lib/app.db",
    "replica": "s3"
  }
]
FieldTypeDescription
pathstringSQLite database path.
replicastringReplica client type configured for the database.

litestream info -json

Outputs daemon process information from the control socket.

json
{
  "version": "v0.5.0",
  "pid": 12345,
  "uptime_seconds": 300,
  "started_at": "2026-04-24T12:00:00Z",
  "database_count": 2
}
FieldTypeDescription
versionstringLitestream version reported by the daemon.
pidnumberDaemon process ID.
uptime_secondsnumberDaemon uptime in seconds.
started_atstringDaemon start time in RFC 3339 format.
database_countnumberNumber of databases currently managed by the daemon.

litestream list -json

Outputs databases managed by the running daemon.

json
{
  "databases": [
    {
      "path": "/var/lib/app.db",
      "status": "replicating",
      "last_sync_at": "2026-04-24T12:00:00Z"
    }
  ]
}
FieldTypeDescription
databasesarrayManaged database summaries.
databases[].pathstringSQLite database path.
databases[].statusstringCurrent daemon state for the database, such as replicating, open, or stopped.
databases[].last_sync_atstringLast successful replica sync time in RFC 3339 format. Omitted if the database has not synced successfully.

litestream ltx -json

Outputs LTX file metadata for the selected database or replica URL.

json
[
  {
    "level": 0,
    "min_txid": "0000000000000001",
    "max_txid": "0000000000000004",
    "size": 8192,
    "timestamp": "2026-04-24T12:00:00Z"
  }
]
FieldTypeDescription
levelnumberLTX compaction level.
min_txidstringMinimum transaction ID in the LTX file.
max_txidstringMaximum transaction ID in the LTX file.
sizenumberLTX file size in bytes.
timestampstringLTX file creation time in RFC 3339 format.

litestream restore -json

Outputs a final summary object after a restore completes. Restore logs are written to stderr so stdout remains parseable JSON.

json
{
  "db_path": "/var/lib/app.db",
  "replica": "file",
  "txid": "0000000000000004",
  "duration_ms": 125,
  "integrity_check": "quick"
}
FieldTypeDescription
db_pathstringRestored database path.
replicastringReplica client type used for the restore.
txidstringRestored transaction ID, when available.
duration_msnumberRestore duration in milliseconds.
integrity_checkstringIntegrity check mode used for the restore: none, quick, or full.

When -dry-run is combined with -json, restore outputs the restore plan instead of the final restore summary.

json
{
  "source": "file:///backups/app.db",
  "target_path": "/var/lib/app.db",
  "replica": "file",
  "min_txid": "0000000000000001",
  "max_txid": "0000000000000004",
  "files": [
    {
      "level": 9,
      "name": "0000000000000001-0000000000000004.ltx",
      "min_txid": "0000000000000001",
      "max_txid": "0000000000000004",
      "size": 8192,
      "timestamp": "2026-04-24T12:00:00Z"
    }
  ]
}
FieldTypeDescription
sourcestringDatabase path or replica URL passed to restore.
target_pathstringDatabase path that would be written by a restore.
replicastringReplica client type used to build the plan.
min_txidstringMinimum transaction ID included in the plan.
max_txidstringMaximum transaction ID included in the plan.
filesarrayLTX files that would be fetched.
files[].levelnumberLTX compaction level.
files[].namestringLTX file name.
files[].min_txidstringMinimum transaction ID in the file.
files[].max_txidstringMaximum transaction ID in the file.
files[].sizenumberFile size in bytes.
files[].timestampstringFile creation time in RFC 3339 format.

litestream status -json

Outputs replication status for configured databases.

json
[
  {
    "database": "/var/lib/app.db",
    "status": "ok",
    "local_txid": "0000000000000004",
    "wal_size": "32 kB"
  }
]
FieldTypeDescription
databasestringSQLite database path.
statusstringCurrent local replication status: ok, not initialized, no database, or error.
local_txidstringLatest local LTX transaction ID, or - if unavailable.
wal_sizestringCurrent WAL file size as human-readable text, or - if unavailable.