Dataclasses

These dataclasses are the in-memory representation of a snapshot. They are serialised to and deserialised from manifest.json via to_storage() and from_storage().

Snapshot

class django_snapshots.Snapshot(version: str, name: str, created_at: datetime, django_version: str, python_version: str, hostname: str, encrypted: bool, pip: list[str], metadata: dict[str, Any], artifacts: list[ArtifactRecord])[source]

Bases: ConfigBase

In-memory representation of a snapshot manifest.

__init__(version: str, name: str, created_at: datetime, django_version: str, python_version: str, hostname: str, encrypted: bool, pip: list[str], metadata: dict[str, Any], artifacts: list[ArtifactRecord]) None
artifacts: list[ArtifactRecord]
created_at: datetime
django_version: str
encrypted: bool
classmethod from_dict(data: dict[str, Any]) Snapshot[source]
classmethod from_storage(storage: SnapshotStorage, name: str, snapshot_format: SnapshotFormat = SnapshotFormat.DIRECTORY) Snapshot[source]

Read and parse manifest.json from storage for the named snapshot.

hostname: str
metadata: dict[str, Any]
name: str
pip: list[str]

pip freeze output captured at export time, one package per element.

python_version: str
to_dict() dict[str, Any][source]
to_storage(storage: SnapshotStorage, snapshot_format: SnapshotFormat = SnapshotFormat.DIRECTORY) None[source]

Serialise and write manifest.json to storage.

version: str

ArtifactRecord

class django_snapshots.ArtifactRecord(type: str, filename: str, size: int, checksum: str, created_at: datetime, metadata: dict[str, ~typing.Any]=<factory>)[source]

Bases: ConfigBase

Immutable record of a generated artifact as stored in the manifest.

__init__(type: str, filename: str, size: int, checksum: str, created_at: datetime, metadata: dict[str, ~typing.Any]=<factory>) None
checksum: str

"sha256:<hex>" of plaintext content.

created_at: datetime
filename: str
classmethod from_dict(data: dict[str, Any]) ArtifactRecord[source]
metadata: dict[str, Any]
size: int
to_dict() dict[str, Any][source]
type: str

Manifest format

A snapshot is stored as a directory (or archive) containing a manifest.json file and one file per artifact. The manifest is never encrypted even when encryption is enabled for artifacts, so it can always be read to determine what a snapshot contains.

{
  "version": "1",
  "name": "2026-03-13_12-00-00-UTC",
  "created_at": "2026-03-13T12:00:00+00:00",
  "django_version": "5.2.0",
  "python_version": "3.12.0",
  "hostname": "prod-web-01",
  "encrypted": false,
  "pip": ["Django==5.2.0", "django-typer==3.6.4"],
  "metadata": {"env": "production"},
  "artifacts": [
    {
      "type": "database",
      "filename": "default.sql.gz",
      "size": 1234567,
      "checksum": "sha256:abc123...",
      "created_at": "2026-03-13T12:00:01+00:00",
      "metadata": {"database": "default", "connector": "PostgresConnector"}
    }
  ]
}

Version history

"1"

Initial format, introduced in django-snapshots v0.1.