Field repository backup formats: text, SQL, zip
Backs the field repository up as the diffable text file (default), an SQL script or a zip of a consistent copy, and restores each of them.
Read this when you want a copy of the field repository for something other than a code review. The default stays the diffable text backup; --format sql writes the DDL and one INSERT per row (a script any SQLite tool reads), --format zip zips a consistent copy of the repository file. repo restore takes the same --format, validates the whole file first and changes nothing when it is damaged.
How to run it
drag-lint repo backup (--repo <file> | --project <project file>) [--format text|sql|zip] [--output <file>]
Full flag list: repo in the CLI reference.
Flags
| Flag | Argument | Meaning | Default |
|---|---|---|---|
--format | text|sql|zip | text |
Where to click
No IDE surface: this feature runs from the CLI (see How to run it).
Details
Three backup formats for the field repository (field-repository). The text backup is the default and stays the committed, reviewable form; the other two are copies for other uses. A backup of the Firebird DATABASE is another verb (repo-db-backup).
drag-lint repo backup (--repo <file> | --project <project file>) [--format text|sql|zip] [--output <file>]
drag-lint repo restore --in <backup file> (--repo <file> | --project <project file>) [--format text|sql|zip] [--replace]
| Format | File | What it is |
|---|---|---|
text (default) | <repo>.txt | The diffable, deterministic text backup. restore(backup(F)) is byte for byte F. |
sql | <repo>.sql | A script: -- DLREPO-SQL <schema version>, one CREATE TABLE line per table, one INSERT per row, a -- end <T> <n> trailer per table. 7-bit ASCII, CRLF, deterministic. |
zip | <repo>.zip | A zip with DLREPO-ZIP.txt (the format marker and the schema version) and repository.sqlite, a consistent copy made by VACUUM INTO. |
--format is the same word for backup and restore, and restore must be given the format the file was written in: a
file of another format is refused as a malformed backup (exit 2), never half read. Without --format nothing changes
from before: the text format.
Restore
- Missing repository: created. For
sqlit is built at the script's own schema version beside the target and renamed on success, so a malformed script never leaves an empty repository behind.zipextracts the copy beside the target and renames it over. - Existing repository: refused unless
--replace(exit 1). - sql parses and validates the whole file first, never executes text from the file (only
INSERTlines of the exact shape are understood), and writes in one transaction. An older script restored into a newer repository gets the data steps ofrepo migrate; a newer script into an older repository is refused ("migrate first"). - zip checks that the file is a zip, that it holds both entries, and that the extracted file opens as a repository
(
PRAGMA quick_check) before it replaces anything. A truncated or foreign archive is refused with a message and exit 2; the repository is unchanged. The repository is replaced as a whole file: no row migration, so an archive of an older schema gives an older-schema repository (repo migrateit).
An unknown value (--format json) is refused before anything is written.
Proof
tests\autotest\run_v156_BKZ.ps1 restores each format into a fresh repository and compares the whole text backup of the
source and the result (golden and edge fixtures), and refuses a truncated zip, a non-zip, a zip without the marker and a
zip whose repository entry is not a repository, each with the target unchanged.