db.backup
SQLite backup/export/restore helpers for the webapp database.
These utilities provide safe, deterministic file-level operations for the webapp SQLite database. They intentionally avoid HTTP concerns and focus on filesystem + SQLite behavior only.
Classes
Summary metadata returned after a backup or export. |
|
Summary metadata returned after a restore/import operation. |
Functions
|
Create a point-in-time backup of the webapp database. |
|
Export the database to a file path. |
|
Restore the webapp database from an existing SQLite file. |
Module Contents
- class db.backup.BackupResult
Summary metadata returned after a backup or export.
- path: pathlib.Path
- class db.backup.RestoreResult
Summary metadata returned after a restore/import operation.
- restored_path: pathlib.Path
- backup_path: pathlib.Path | None = None
- db.backup.backup_database(db_path, *, output_path=None, overwrite=False)
Create a point-in-time backup of the webapp database.
- Parameters:
db_path (pathlib.Path) – Source SQLite database to back up.
output_path (pathlib.Path | None) – Optional destination file. When omitted, a timestamped sibling file is created next to
db_path.overwrite (bool) – When
True, allow replacing an existing file.
- Returns:
BackupResultwith the path and content hash of the backup.- Return type:
- db.backup.export_database(db_path, *, output_path, overwrite=False)
Export the database to a file path.
This is a convenience wrapper over
backup_database()that keeps the naming explicit for API users.
- db.backup.restore_database(db_path, *, import_path, overwrite=False, create_backup=True, backup_path=None)
Restore the webapp database from an existing SQLite file.
- Parameters:
db_path (pathlib.Path) – Destination database path used by the webapp.
import_path (pathlib.Path) – Existing SQLite file to restore from.
overwrite (bool) – When
True, allow replacing an existing destination DB.create_backup (bool) – When
Trueand the destination exists, create a timestamped backup first.backup_path (pathlib.Path | None) – Optional explicit backup path used when
create_backupis enabled.
- Returns:
RestoreResultwith the restored DB path and optional backup path.- Return type: