Menu
Buy VPS
Payments
Tools
User

DropVPS Team

Writer: Cooper Reagan

How to Install Litestream on a VPS for SQLite Replication

How to Install Litestream on a VPS for SQLite Replication

Publication Date

Category

How To

Reading Time

3 Min

Table of Contents

Litestream is a free, open-source tool that continuously replicates a SQLite database to remote storage, such as S3-compatible object storage, in real time. This guide walks through installing Litestream on a VPS and setting it up to replicate a SQLite database.

Before starting, connect to your VPS via SSH with a user that has sudo privileges. You'll also need access to an S3-compatible storage bucket, such as Amazon S3, Backblaze B2, or DigitalOcean Spaces, to hold the replicated data.

Step 1: Download and Install Litestream

Litestream provides prebuilt Debian package files, which is the simplest way to install it on Ubuntu or Debian. Download the latest release:

wget https://github.com/benbjohnson/litestream/releases/download/v0.5.8/litestream-0.5.8-linux-amd64.deb

Install the package:

sudo dpkg -i litestream-0.5.8-linux-amd64.deb

Confirm the installation succeeded:

litestream version

Step 2: Configure Litestream

Litestream is configured through a YAML file located at:

/etc/litestream.yml

Open the file and define which database to replicate and where the replica should be stored:

dbs:
  - path: /path/to/your/database.db
    replicas:
      - type: s3
        bucket: your-bucket-name
        path: db-backup
        region: your-region
        access-key-id: YOUR_ACCESS_KEY
        secret-access-key: YOUR_SECRET_KEY

Replace the path, bucket name, region, and credentials with your own values. Litestream also supports other backends, including Azure Blob Storage, Google Cloud Storage, Backblaze B2, and SFTP, configured the same way with a different type value.

Step 3: Run Litestream as a Systemd Service

The Debian package installs a systemd service alongside Litestream, so it can run continuously in the background and restart automatically if the server reboots. Enable and start it:

sudo systemctl enable litestream
sudo systemctl start litestream

Check that the service is running correctly:

sudo systemctl status litestream

Litestream will now watch your SQLite database's write-ahead log and stream every change to your configured storage backend continuously, with replication lag typically under a second.

Step 4: Verify Replication Is Working

Confirm that Litestream is actively replicating by checking its logs:

journalctl -u litestream -f

You can also list the current generations of your replicated database, which confirms data is reaching the remote storage:

litestream generations /path/to/your/database.db

Step 5: Restore the Database if Needed

If your VPS ever fails or the database file is lost, Litestream can restore it from the replica with a single command:

litestream restore -o /path/to/your/database.db s3://your-bucket-name/db-backup

This rebuilds the database file to its most recent replicated state, giving you a fast, low-effort way to recover from data loss without maintaining a separate database server.

Running Litestream continuously in the background works best on infrastructure with reliable uptime and network access. A Linux VPS gives you the root access and stable connectivity needed to keep replication running consistently.

Related Guide

Linux VPS Hosting Plans

Get a Linux VPS with the reliable uptime Litestream needs to keep your SQLite database continuously replicated.

With Litestream running, your SQLite database stays continuously backed up in the background, giving you a simple, near real-time safety net without the overhead of running a separate database server.

Linux VPS
๐ŸงLinux VPS

Need a Linux Server for This?

Run Debian, Ubuntu, or any Linux distro on DropVPS โ€” fast NVMe SSD, full root access, and 24/7 support. Perfect for everything you just read.

  • Full Root Access
  • Debian & Ubuntu Ready
  • 99.99% Uptime
  • 24/7 Support
Get Linux VPS โ†’

No commitment ยท Cancel anytime

U
Loading...

Related Posts