Skip to content

Instantly share code, notes, and snippets.

@entron
Created August 13, 2016 09:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save entron/e8c7e69efcb81268328c58ca0f864a31 to your computer and use it in GitHub Desktop.
Save entron/e8c7e69efcb81268328c58ca0f864a31 to your computer and use it in GitHub Desktop.
Online backup sqlite db with python
# Online backup a sqlite3 DB.
# python3 sqlite_online_backup.py db_to_backup.sqlite backup_db.sqlite
import sqlite3
import sqlitebck
import sys
fname_to_backup = sys.argv[1]
fname_backup = sys.argv[2]
conn_to_backup = sqlite3.connect(fname_to_backup)
conn_backup = sqlite3.connect(fname_backup)
sqlitebck.copy(conn_to_backup, conn_backup)
conn_to_backup.close()
conn_backup.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment