pub async fn write_backup_pair(
scope_dir: &Path,
table: &str,
schema_yaml_path: &Path,
db_path: &Path,
) -> Result<(), MiniAppError>Expand description
Creates a backup pair (YAML + SQLite DB snapshot) for a table.
The pair is written to {scope_dir}/_backup/{table}.{unix_secs}.yaml and
{scope_dir}/_backup/{table}.{unix_secs}.db. The _backup directory is
created if it does not exist.
The YAML file is copied verbatim from schema_yaml_path. The DB file is
created via rusqlite::Connection::backup("main", …, None) using a fresh
read-only connection (the existing Store connection is not touched).
A PRAGMA wal_checkpoint(TRUNCATE) is attempted before the backup to
ensure the WAL is flushed. If the checkpoint fails it is logged as a
warning and the backup continues regardless (rusqlite’s backup API handles
WAL-mode databases internally).
§Arguments
scope_dir: the.mini-app/<scope>/root directory for this table.table: the logical table name (used as filename prefix).schema_yaml_path: path to theschema.yamlfile to back up.db_path: path to the SQLite database file to back up.
§Returns
Ok(()) on success.
§Errors
MiniAppError::Backupif the timestamp cannot be determined, the backup directory cannot be created, the YAML copy fails, or the SQLite backup fails.MiniAppError::Backupif thespawn_blockingtask panics.