Replicate every database under a prefix
sudo litebackup replicate --prefix app/ --to /var/lib/app/replicas
Each database lands at its name after the prefix, such as /var/lib/app/replicas/main.sqlite.
Read it with any driver
A replica is an ordinary SQLite file, so any driver in any language reads it, with no client library. It is usually a few seconds behind the database it copies.
Keep writes out
--write-protection |
When an app writes to the replica |
|---|---|
lock (default) |
The write fails with SQLITE_BUSY, and reads carry on. |
detect |
Litebackup notices the write and brings the replica back in sync. |
none |
Nothing stops it, so open the file readonly (mode=ro). |
In the SDK it is writeProtection (TypeScript) or WriteProtection (Go).
Manage replicas
litebackup replicate list shows each replica and its version. litebackup replicate stop app/main.sqlite stops one and leaves the file in place.
What replicas are for
- Reads close to users. Serve reads from every server instead of one.
- Reports and analytics. Run heavy queries on a copy, away from the database your app writes.
- A warm standby. With failover, a replica takes over writes when the origin goes down.
Send writes to one machine
One machine writes each database, and the rest read. To move writes between machines, use failover, or acquire and release in the SDK for worker pools.
Next time
- The database you replicate is backed up too, so you can restore any version you keep.
- How to back up SQLite compares the ways to back up.
Get started
Install your Litebackup server and back up a first database in minutes: get started, or see pricing.