Archive replication¶
media.dvr.replication
Replication stores additional copies of archive fragments on another streamer. Transparent playback of history that remains on previous servers after a camera is moved is covered in remote archive access.
Typical tasks this solves:
- migrating to a new server without losing history — the new one records fresh archive, the old one keeps the past;
- reading the archive from replica servers;
- recovering after a disk replacement.
In a cluster, the layouter in central handles authorization of requests between servers. It generates the server interaction configuration; separate manual permissions for every server pair are not required.
Configuration¶
streams:
- name: cam1
inputs:
- rtsp:
url: rtsp://10.0.0.5/stream0
dvr: {}
remotes:
- url: http://old-server:5080
timeout_ms: 5000
| Parameter | Description |
|---|---|
url |
address of the remote Sapsan server that has this stream's archive |
timeout_ms |
timeout for requests to the remote server |
There can be several remote servers — Sapsan queries them all.
Lazy replication¶
When DVR recording is configured and archive disks are available, historical fragments read from remote servers can be saved to the local archive. Encrypted content and fragments at the live edge are excluded from this write-through. The local archive gradually gains the parts of remote history that viewers watch; a failure to save them does not prevent delivery to the viewer.
Replication writes foreign history onto archive disks and keeps it there until retention cleans it up. When a server should not relocate the archive but merely save network on what is popular, that is the archive cache: separate cache disks, eviction by last access, and operation without archive disks at all.
Failure behavior¶
- If a remote server is unreachable but the data exists locally, playback continues; the problem is only logged.
- Sapsan remembers which ranges are absent on a remote (negative cache) and does not re-query it for missing data.
- Init fragments of remote streams are cached.
How seamlessness works¶
On every archive access Sapsan merges local and remote data:
- Archive ranges — available intervals from all servers are combined. Actual gaps without recordings are preserved.
- Playlists — fragment lists from the local DVR and remote servers are merged, sorted, and deduplicated. Missing recordings are not reconstructed.
- Fragments — read in a cascade: live buffer → local DVR → remote server. The fragment URL is the same for the player regardless of where the data lives.
Stable addressing makes this possible: a fragment is identified by stream name, track, and integer timestamp with its timescale. Its address remains the same on every server during replication and clustering, so merging archives does not require timeline recalculation.