Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,113 of 9,113 pages
About the help in other languages
All help pages

Back up a SQLite site safely

Step by step - back up an Exponential site that runs on SQLite 3 without stopping it, with the sqlite3 .backup command instead of a file copy, and schedule it.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/government/tasks/operations/back-up-a-sqlite-site-safely.md

On this page

Back up a SQLite site safely

This task is for administrators of sites on SQLite 3, the default database for a site served from one machine. At the end you have a consistent copy of the database. A plain file copy of a database in use can be inconsistent; the .backup command of the sqlite3 tool is safe (Operating a site, section 6).

Contents

  1. Before you start
  2. Steps
  3. Schedule it
  4. Check it worked
  5. Related pages

Before you start

  • The sqlite3 command-line tool on the server.
  • The database file name: ls var/storage/sqlite3/ (exponential.db is the name exp:install uses by default).
  • A target directory outside the installation, ideally on another volume.

Steps

sqlite3 var/storage/sqlite3/exponential.db ".backup '/backup/example/site-$(date +%F).db'"
tar czf /backup/example/files-$(date +%F).tgz var/storage settings/override settings/siteaccess

The database is several files (.db, -wal, -shm, .writer-lock); .backup reads it through SQLite and writes one consistent file, so you do not copy the others.

Schedule it

A nightly crontab line as the site's user (adapt paths):

30 2 * * * cd /path/to/installation && sqlite3 var/storage/sqlite3/exponential.db ".backup '/backup/example/site-nightly.db'"

Rotate the copies by your retention rule (Backup schedules and retention).

Check it worked

sqlite3 /backup/example/site-nightly.db "PRAGMA integrity_check;"     # ok

Then restore it on a test server now and then (Restore last night's backup to a test server).

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x