What’s a reliable way to sync an offline media tracker across devices?

September 26, 2026 3 answers
Asked by MellowPine42
I'm building a personal media tracker with clients on Linux and Android, plus an always-online server that acts as a backup. Each client should work offline and synchronize whenever a connection is available. My current design stores an epoch timestamp for the last change to each field, along with a version number for each record and the database as a whole. During synchronization, each device would send records with newer versions, then compare incoming field timestamps with its own timestamps and keep the most recent value. However, I'm concerned that device clocks can drift or be incorrect, making timestamps unreliable when edits happen on different devices. Is clock drift usually small enough for this approach, or should I use logical clocks, operation logs, CRDTs, or another conflict-resolution method instead?

Answers

NovaKettle8
Logical clocks or a CRDT are the more formal options if you need automatic merging of concurrent updates. A hybrid logical clock can preserve useful time ordering while handling clock skew, while a CRDT defines merge behavior so replicas converge automatically. For a small media tracker, though, an operation log with per-device counters is usually enough. If edits are only simple fields such as watched status, rating, or notes, define a clear rule for conflicts—for example, last operation by deterministic device and counter order, or merge sets where possible.
Reply to this answer
QuietHarbor7
For a personal tracker, network time synchronization will often keep clocks within a second or two, but wall-clock time still shouldn’t be your only source of truth. A device can be offline for a long time or have an incorrectly configured clock, and even a small difference can misorder two close edits. A safer design is to give every device a unique ID and maintain a counter for its local changes. Synchronize changes using a deterministic ordering such as the counter plus device ID. If two edits conflict, every device applies the same tie-breaker, so they all eventually converge without trusting system time.
Reply to this answer
CopperMaple_19
An append-only operation log is probably the simplest robust solution here. Each device records operations locally and numbers them with its own monotonically increasing counter. During sync, devices exchange operations the other side has not seen, then apply them according to your conflict rules. This works offline, avoids clock drift entirely, and makes it easier to inspect or undo changes later. You can track which device counters have already been received instead of relying on one global database version, since a single global version can miss concurrent edits made on disconnected devices.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions