Skip to content

Roll back one customer, not everyone.

Revert Acme's database to just before yesterday's bad import while every other customer keeps working.

Back up every tenant

Install your [Litebackup server](/install), then join the app machine and back up its tenant databases under tenants/.

# Join this machine and back up every tenant database.
# Use the token from Machines, Add machine in your console.
curl --fail --silent --show-error --location https://litebackup.com/cli.sh | bash
litebackup install service --api-key YOUR_JOIN_TOKEN@HOST
litebackup start '/var/lib/app/tenants/*.sqlite' tenants/

Recover one customer at a time

These examples use a backed up database named tenants/acme.sqlite, an SDK client on the local daemon, and version 120 as the retained version from before the mistake.

  • Shared tables make recovery a merge

    When customers share tables, recovering one account can mean restoring the whole database into a temporary instance, extracting that customer’s rows across related tables, and merging them back while preserving relationships and everyone else’s newer changes.

  • One database per customer makes recovery one operation.

    With one SQLite database per tenant, each customer has separate versions, so a bad import, a buggy migration, or an accidental delete can be rolled back for that customer without changing another customer’s database.

1. Find the version before the mistake

List Acme's retained versions with their times and pick the one from before the import.

# List Acme's retained versions with their times.
# Use --stdout-format json if you also need digests.
litebackup versions tenants/acme.sqlite

2. Preview Acme’s database before the import

Restore the chosen version to a new file and inspect it while the live database stays untouched.

# Preview the version chosen from Acme’s list.
litebackup restore tenants/acme.sqlite /tmp/acme-before-import.sqlite --version 120

3. Roll back Acme’s account

Once the preview checks out, pause Acme's work, close its connections, let its writes sync, and revert on its writer machine.

# Make the checked version Acme’s current database again.
litebackup revert tenants/acme.sqlite --version 120

Preview without changing the live database

restore writes a new file and runs SQLite’s quick_check before returning. The destination directory must exist and the file must not exist. Open the copy separately to check Acme’s records and test the app against the old schema before deciding to revert.

Choose a time instead

Both restore and revert accept --time with an RFC 3339 timestamp instead of --version. They select the newest retained version at or before that time. Replace this example time with a moment before Acme’s import.

# Preview Acme’s database at or before the chosen time.
litebackup restore tenants/acme.sqlite /tmp/acme-before-import.sqlite --time 2026-11-28T09:00:00Z

After inspecting the preview, pause Acme as in step 3 before applying the same time.

# Roll back Acme’s database to the chosen time.
litebackup revert tenants/acme.sqlite --time 2026-11-28T09:00:00Z

These are alternatives to the version examples. Each SDK also accepts a time in place of a version. See the restore guide and SDK reference.

Undo the rollback

A revert replaces Acme’s whole database with the chosen version, including its schema. Valid changes made after that version are absent from the current database too.

Revert puts the chosen content back under Acme’s database name as a new head, one version beyond the current head. Like git revert adding a commit, it adds to the version list rather than erasing later versions. Those versions remain restorable for as long as retention keeps them. Revert to the version from before the rollback to undo it.

The revert changes only Acme’s database. Other tenants keep their current databases and changes. Resume Acme’s work after the revert succeeds and the app can use the restored database.

Offer customers an undo action

An admin or support action in your SaaS can use the same SDK calls. Your app checks who may recover the account and maps that account to its database name. List that database’s versions so the person can choose one to preview.

const versions = await litebackup.databases.versions("tenants/acme.sqlite");

After the person checks the preview and confirms the rollback, pause Acme as in step 3 and revert to the chosen version on its writer machine.

await litebackup.databases.revert("tenants/acme.sqlite", { version: 120 });

Your app supplies the customer interface, permission checks, and coordination with its workers. Litebackup supplies the version list, preview restore, and revert. A database per tenant makes the rollback one operation without extracting or merging shared tables.

Questions

What happens to Acme’s writes after the bad import?

A revert replaces Acme’s whole database with the chosen version, including its schema. Valid changes made after that version are absent from the current database too. Later captured versions remain restorable under retention. If Acme needs those newer changes, use the preview to work out a selective repair instead of reverting the whole database. The deleted rows guide shows how to copy selected rows back.

What if the app is writing during revert?

Pause Acme as in step 3. Revert refuses an open file with still_open. If the file holds writes the server lacks, it refuses with conflict and leaves the file untouched. This protection prevents overwriting unsynced writes. It does not preserve newer changes that have already synced when you choose an older version.

How far back can I go?

Only as far as the versions Litebackup captured and still retains. Choose retention in the console under Retention, and use litebackup versions tenants/acme.sqlite to see what is available now. A time selects a retained version at or before it. It does not reconstruct individual transactions between captured versions.

Can I do this with customers in shared tables?

Litebackup restores or reverts a whole SQLite database. It does not select a tenant’s rows, track dependencies across tables, or merge them into a shared database. A separate database per customer is what makes the per-customer rollback a single operation.

Install

Install Litebackup, then back up your tenant databases. The examples above show the calls after setup. Backups must already contain a version from before the mistake. See pricing for plans.