The core here is my first attempt at a solution of this, combining ideas from and karlicoss/HPI/ to create a library/CLI tool to (as safely as possible) copy databases which may be in use from other applications


This exposes the python stdlib sqlite.backup function as a library, with a couple extra steps.

The main purpose for writing this is to copy sqlite databases that you may not own -- perhaps it belongs to an application (your browser) and is locked since that's currently open, or the OS keeps it open while the computer is active (e.g. Mac with iMessage)


  • Has the option (true by default) to first safely copy the database from disk to a temporary directory, which is:
  • useful in case the source is in read-only mode (e.g. in some sort of docker container)
  • safer if you're especially worried about corrupting or losing data
  • Uses Cpythons Connection.backup, which directly uses the underlying Sqlite C code

In short, this prioritizes safety of the data over performance, temporarily copied data files to /tmp or memory usage - because we often don't know what the application may be doing while we're copying underlying sqlite databases

This was extracted out of the karlicoss/HPI sqlite module

If other tools exist to do this, please let me know!


Requires python3.7+

To install with pip, run:

pip install sqlite_backup


TODO: Fill this out

Usage: ...


git clone ''
cd ./sqlite_backup
pip install '.[testing]'
mypy ./sqlite_backup
GitHub - seanbreckenridge/sqlite_backup at
a tool to snapshot sqlite databases you don’t own. Contribute to seanbreckenridge/sqlite_backup development by creating an account on GitHub.