Import, export, transfer
create — Create a database
Create a new database file with optional metadata.
./blunderdb create --db <path> [--user <name>] [--description <text>] [--force]
Options:
--db— Path to the database file to create (required).--user— Database owner name.--description— Database description.--force— Overwrite the file if it already exists.--format— Output format:text(default) orjson(path, version, user, description, creation date).
The .db extension is added automatically if missing. Parent directories are created as needed.
Example:
./blunderdb create --db mes_matchs.db --user "Jean" --description "Matchs de tournoi 2025"
import — Import data
Import match or position files into the database.
./blunderdb import --db <path> --type <type> [options]
Options:
--db— Path to the database (required).--type— Import type:match,positionorbatch(required).--file— File to import (formatchandposition).--dir— Directory to import (forbatch).--recursive— Recursively scan subdirectories (default: yes).--watch— With--type batch: does not stop, and imports each match file as it appears in--dir(Ctrl-C to stop).--watch-every— How often--watchlooks (default: 10s, floor 2s).--resume— With--type batch: resumes the batch with this number (shown when the import starts, orbatch_idin JSON). Files with the same path, size and date as in its log are skipped without being read, those with the same content are read but not analysed; files in error are retried.--format— Output format:text(default) orjson.--fail-on-error— Fails if at least one item (positionorbatch) could not be imported, even when others succeeded.--skip-duplicates— Skips a match already in the database without taking its deeper analyses (study marks are still applied). By default, a duplicate replaces each stored analysis with its own when it is strictly deeper, and the line says so:DUPLICATE (N analyses deepened).
A decision whose analysis holds a value that is not a finite number (NaN or infinity) is imported without that analysis, and the rest of the match comes in as usual; the batch report gives their number (Decisions imported without their analysis).
The exit code follows four rules:
nothing was recognised — every file failed — : error, whether
--fail-on-erroris passed or not;only duplicates — every file was already in the database — : success. A directory re-run with no new file, a script’s ordinary night, exits with 0 and only
duplicatesnon-zero;partial failure (some items imported, others rejected): error only if
--fail-on-erroris passed;at least one new item imported, without
--fail-on-error: success, with the rejected files listed in the table.
Watching a folder
--watch turns the directory import into a watch: the command does not return, and imports each match file that appears in the folder. It is the headless form of the application’s watched folder.
# Importer ce que le dossier contient déjà, puis surveiller ce qui arrive
./blunderdb import --db base.db --type batch --dir ~/XG/Matches
./blunderdb import --db base.db --type batch --dir ~/XG/Matches --watch
Only files that appear are imported: whatever the folder holds at start-up is recorded as known and left alone — pointing a watch at four years of matches must not import all of them. The two commands above therefore compose exactly as one would hope.
A file is imported only once its size has settled, that is, seen twice unchanged: a match another program is writing grows from one look to the next, and importing it half-written would give a syntax error nobody can act on. The folder is not walked recursively. A network share that has become unreadable does not stop the watch, and its contents do not pass for new when it comes back.
A .db database that appears in the folder is merged as by import --type database: this is how the incremental export of another machine arrives (see Synchronising two machines).
Ctrl-C stops between files, never inside one: the file being imported finishes and its report is printed before the command returns.
Import a match
Supported formats: eXtreme Gammon (.xg, .xgp), GNUbg (.sgf), Jellyfish (.mat, .txt), BGBlitz (.bgf) and HedgeHog (.ogxm).
./blunderdb import --db base.db --type match --file match.xg
# Successfully imported match (ID: 1)
#
# Match Details:
# Players: Kévin Unger vs Maxence Job
# Event: HSBT Paris 2023
# Match Length: 7
# Games: 7
--format json delivers the same fields in a single document:
{
"type": "match",
"match_id": 1,
"player1": "Kévin Unger",
"player2": "Maxence Job",
"event": "HSBT Paris 2023",
"location": "Paris, Fédération Française de Bridge",
"match_length": 7,
"games": 7
}
Import positions
Imports positions from a text file, one JSON position per line. This is exactly what export --type positions writes: the two commands answer each other, an export re-imports as is, with nothing to touch up.
./blunderdb import --db base.db --type position --file positions.txt
# Successfully imported 4 positions
A line, as export produces it — the board takes up most of it, twenty-six points followed by the checkers off:
{"id":1,"board":{"points":[{"checkers":0,"color":0},{"checkers":1,"color":1},…],"bearoff":[0,0]},"cube":{"owner":-1,"value":0},"dice":[0,0],"score":[7,7],"player_on_roll":0,"decision_type":1,"has_jacoby":0,"has_beaver":0,"individually_imported":true,"flagged":false}
The analysis and the comments do not travel through this format: it carries the position, nothing else. To move an entire library, export --type database is the one to use.
Importing a database
Merges another blunderDB database (.db) into the one given by --db, by the rules of the desktop application’s merge and of imports.db in server mode (Merge a database): positions, matches, tournaments, collections, lessons, Anki decks, drafts and aliases, as well as the tournaments’ Direction and their Encounter. Importing the same file twice changes nothing. The text output counts the matches added and already present, the Directions and Encounters read back, and names the living collections frozen or left on a manual list, and the families the database is too old to carry.
--analyze counts what the file would bring — its positions and those the database already holds, its new or already present matches, its collections, lessons and Anki decks — without importing anything; it is the same computation as imports.dbAnalyze in server mode. --max-positions N brings in at most N positions, taken among the first N of the file in the order of their original identifier. A match, a collection, a lesson or a deck that touches a position left out is left out entirely; so is a position that nothing would hold after the import (no match or collection brought in, no lesson, no deck, no individual import, no user comment, no study mark). So a later import without a cap brings in complete what was missing. The output counts, family by family, what was left out. An error or an interruption during the import writes nothing: the whole merge fits in one transaction.
./blunderdb import --db base.db --type database --file club.db
./blunderdb import --db base.db --type database --file club.db --format json
./blunderdb import --db base.db --type database --file club.db --analyze
./blunderdb import --db base.db --type database --file club.db --max-positions 5000
Batch import
Import all match files from a directory in a single operation. This is the most efficient method for importing a large number of matches.
./blunderdb import --db base.db --type batch --dir ./matchs/
./blunderdb import --db base.db --type batch --dir ./matchs/ --recursive=false
./blunderdb import --db base.db --type batch --dir ./matchs/ --format json --fail-on-error
A summary table shows for each file whether the import succeeded (✓), failed (✗) or was a duplicate (⊘). A duplicate is not counted as a failure, and a batch containing only duplicates is a success (see the rules above).
Each file of the batch is logged (path, size, date, SHA-256, resulting match or error). The batch number is shown at the start; if the import is interrupted, --resume continues it without analysing again what is already decided. With --format json, the final object carries batch_id and the journal array.
./blunderdb import --db base.db --type batch --dir ./matchs/ --resume 12
Batch importing from: ./matchs/ (recursive: true)
Found 3 match file(s) to import
[1/3] Importing: 02_NDT_FR.txt... ERROR: failed to parse file: ingest: parse gnubg file: invalid MAT file: no match header found
[2/3] Importing: test.mat... DUPLICATE
[3/3] Importing: test.xg... OK (ID: 1, 341 positions)
====================================================================
IMPORT SUMMARY
====================================================================
Status File ID Player 1 Player 2 Games Positions Error
------ ---- -- -------- -------- ----- --------- -----
✗ 02_NDT_FR.txt 0 0 failed to parse file: ingest: ...
⊘ test.mat 0 0
✓ test.xg 1 Kévin Unger Maxence Job 7 341
--------------------------------------------------------------------
Total: 3 files | Success: 1 | Duplicates: 1 | Failed: 1 | Positions imported: 341
--format json gives the same thing in a script-friendly form: one object per file in files, then the totals. A quiet night leaves duplicates alone non-zero and failed at zero, with the exit code at 0; only a batch where nothing was recognised exits in error.
{
"files": [
{"file_path": "02_NDT_FR.txt", "success": false, "error": "failed to parse file: …"},
{"file_path": "test.xg", "success": true, "positions": 341}
],
"total": 3,
"success": 1,
"duplicates": 1,
"failed": 1,
"positions_imported": 341
}
export — Export data
Export database contents to files.
./blunderdb export --db <path> --type <type> --file <output> [options]
Options:
--db— Source database (required).--type— Export type:database,positions,matchesormat(export of one or more matches as a Jellyfish.mattranscript) (required).--file— Output file (required, except for--type matused with--dir).--dir— Output directory for batch.matexport (several matches, one file per match; without--match-ids, all matches are exported).--analysis— Include analysis (default: yes).--comments— Include comments (default: yes).--filters— Include filter library (default: yes).--played-moves— Include played moves (default: yes).--matches— Include matches (default: yes).--transcriptions— Include the transcription draft of each exported match (default: yes).--aliases— Include the player and event aliases the exported matches write, so that the merging of players follows them (default: yes).--collections— Include collections (default: yes).--tournaments— Include tournaments (default: yes).--decks— Include the Anki decks (default: yes).--lessons— Include lessons, with the collections and positions their steps show (default: yes).--anki-history— Carry the review history of the exported decks: the state of each card and the log of its reviews (default: yes).--collection-ids— IDs of the collections to export (comma-separated, empty = all).--match-ids— Match IDs to export (comma-separated, empty = all).--tournament-ids— IDs of the tournaments to export (comma-separated, empty = all).--deck-ids— IDs of the Anki decks to export with their positions (comma-separated, empty = all).--lesson-ids— IDs of the lessons to export (comma-separated, empty = all).--password— Wraps the result in an encrypted container (.dbx).--watermark— Writes a signed statement of origin into the exported file (see Handing out a database: origin and password).--watermark-note— Free text attached to the watermark (terms of use, contact); used together with--watermark.--format— Output format:text(default) orjson(a document summarising the export: path, size in bytes, counts).--incremental— With--type database: exports only what has entered the library since the last incremental export to the same folder, then advances that marker in the exported database.--filecan then be a folder, where async-<machine>-<date>.dbfile is created (see Synchronising two machines). A file name already taken is refused: the file in place holds the previous delta, which the other machine may not have merged yet.--sync-cursor— With--incremental: name of the marker read and advanced, in place of the destination folder.--plan— With--type databaseormatches: counts, family by family, what the export would write, without writing a file (--fileis then optional). The counts are those that the export reports afterwards; live collections that would leave frozen and the “recherche” decks whose source would lose a part are named. With another type, the option is refused.--plan-ids <famille>— Like--plan, but returns a page of the identifiers behind a count:positions,comments(the positions that carry them),matches,tournaments,directions(the tournaments whose Direction leaves with them),rencontres(the events that leave with one of their tournaments),collections,lessons,ankiDecks,transcriptionsorfilters.--offsetand--limitchoose the page (1000 identifiers at most).
--type database exports the whole library, like the server export and like the export window when the displayed list is the library: positions, matches, tournaments (with their Direction: journal, pairs, tables and the filing of the exported matches; their event leaves as soon as one of its tournaments does), collections, lessons, Anki decks, transcriptions, aliases and filters. An option set to false removes its family (--collections=false); a list of IDs restricts it to those items and includes it. A transcription draft leaves with the match it produced; a draft that has not yet produced a match leaves only if every match does. --type matches also carries each match’s draft.
Examples:
./blunderdb export --db base.db --type database --file sauvegarde.db
./blunderdb export --db base.db --type positions --file positions.txt
./blunderdb export --db base.db --type matches --file selection.db --match-ids 1,3,5
# .mat : un match, puis plusieurs (ou tous) dans un répertoire
./blunderdb export --db base.db --type mat --match-ids 5 --file match5.mat
./blunderdb export --db base.db --type mat --match-ids 5,9,12 --dir sorties/
./blunderdb export --db base.db --type mat --dir sorties/
# Ce qui est nouveau depuis le dernier export vers ce dossier, pour une
# autre machine qui le surveille
./blunderdb export --db base.db --type database --incremental --file ~/Sync/vers-portable/
# .dbx : filigrané et protégé par mot de passe
./blunderdb export --db cours.db --type database --file cours-diffusion.dbx \
--watermark "Cours de Jean Dupont — 12 mars 2026" \
--watermark-note "Merci de ne pas rediffuser." \
--password secret
A watermark is signed with the local issuer identity (see the identity command below): it cannot be forged, but it can be removed — the file remains an ordinary SQLite database. It protects nothing; it only states where the file came from. A password protects the file’s transport (the stray copy, the attachment sent by mistake), not the database itself: whoever has the password can open it. blunderDB never records anything on the recipient’s side (no registry, no log) — see ADR-0007.
transfer — Copy from one library to another
Copies part of a library into another, with no intermediate file to handle. The selection is that of export --type database; the merge is that of importing a .db database: a position the destination already holds is not added a second time (it is recognised by its hash), its analyses and comments are merged, and a match, collection, lesson or Anki deck already present is not duplicated. Copying from A to B then from B to A therefore creates no duplicate.
./blunderdb transfer --from <source.db> --to <destination.db> [options]
Options:
--from— Source library (required; it must exist and use the schema of this version of blunderDB). An older library is refused, because upgrading it would mean writing to it: open it once in blunderDB. A newer library is refused too: update blunderDB.--to— Destination library (required; created if it does not exist). It cannot be the source.--analysis,--comments,--played-moves,--matches,--transcriptions,--aliases,--collections,--tournaments,--decks,--lessons— As forexport: an option set tofalseremoves its family (default: yes for all).--collection-ids,--match-ids,--tournament-ids,--deck-ids,--lesson-ids— A list of IDs from the source restricts its family to those items and includes it. An ID that the source does not contain is an error, and nothing is copied.--format—text(default) orjson(what was read from the source and what the destination took from it).
Which positions are sent. Without a list of IDs, all positions of the source are sent, filed or not. As soon as a list of IDs is given, only the positions reached by the retained families are sent (the members of a collection, the moves of a match, the steps of a lesson, the cards of a deck), with their analyses and comments. A collection always goes with its members. A match named by --match-ids carries the record of its tournament (name, date, venue), but not the other matches of that tournament; with --tournaments=false, it arrives without a tournament.
Nothing is written that says where the copy comes from: no watermark, no import log, no metadata from the source; the destination keeps its own, and the source receives nothing. The filter library and the review history of Anki decks are not copied: a deck arrives without history, and a deck of the same name already present keeps its own.
Examples:
# Toute une bibliothèque dans une autre
./blunderdb transfer --from club.db --to perso.db
# Deux collections et leurs positions, rien d'autre
./blunderdb transfer --from club.db --to perso.db --collection-ids 3,7 \
--matches=false --tournaments=false --lessons=false --decks=false
# Un match, ses positions et son tournoi, en retour
./blunderdb transfer --from perso.db --to club.db --match-ids 12 \
--collections=false --lessons=false --decks=false
The server offers the same transfer between two tenants, pulled by the receiving tenant (see Pulling a copy from a read tenant).
identity — Issuer identity
Shows or moves your issuer identity: the Ed25519 key that signs every watermark. It is created on its own the first time a watermark is applied; there is nothing to configure. It belongs to a person, not to a database: everything you mark carries a single public fingerprint.
./blunderdb identity
./blunderdb identity --name "Jean Dupont"
./blunderdb identity --export jean.bdbid --passphrase pw
./blunderdb identity --import jean.bdbid --passphrase pw
Options:
--name— Changes the identity’s display name.--export— Exports the identity to a.bdbidfile.--import— Imports an identity from a.bdbidfile.--passphrase— Optional passphrase protecting the exported/imported file (the local identity itself is deliberately left unprotected).--format— Output format:text(default) orjson(name, fingerprint, storage path).
The exported file lets anyone holding it sign in your name — do not share it. Renaming changes a label and nothing else: files already marked keep the name they were sealed under, and still verify.
open — Opening a protected file
Turns a password-protected file (.dbx) into an ordinary database. The password is asked once; after that it is a normal file.
./blunderdb open --db cours.dbx --password secret
./blunderdb open --db cours.dbx --password secret --file ./mon-cours.db
Options:
--db— The.dbxfile to open (required).--password— The container’s password (required).--file— Output path for the ordinary database (default: same name,.dbextension).
What the password protects: the file’s transport — the copy left in a downloads folder, the attachment sent by mistake. Not the database: whoever has the password can open it. The container’s header is in the clear, so blunderdb info reads the origin of a protected file without its password.