Import, export, and backup
Import and export move vault entries between Rowel and other password tools. Backups preserve a complete encrypted vault for recovery or device setup. The frontend chooses the user flow while native commands read files, translate data, protect secrets, and write or restore vault data. The core import service separates format conversion from vault access. This page complements Vault data and sync, Vault lifecycle and persistence, and Workspace and sync.
Data transfer paths
The system separates migration from recovery. A third-party import parses entries and adds new content to an open vault. A .rowel backup restores a complete vault during first-run setup. A legacy .swftx file is an encrypted vault merge for an already open vault.
The main paths are:
- Third-party import: choose or drop a JSON or CSV export, preview the result, then commit it to the open vault.
- Third-party export: choose Bitwarden JSON, CXF JSON, or generic CSV, then save a plaintext export through a native save dialog.
- Vault backup: verify the current vault password and save an encrypted
.rowelsnapshot. - Backup restore: use a
.rowelfile during first-run setup to create the local vault from that snapshot. - Legacy merge: provide a
.swftxpassword and merge its entries into the open vault. - Environment file transfer: read a .env file into an environment entry or save a revealed environment entry back to disk.
The frontend APIs in src/…/imports.ts, src/…/vault.ts, and src/…/setup.ts expose these paths as typed commands. Native code owns file access and vault boundaries, so a migration cannot write plaintext rows directly into storage. The core import service is byte-in and result-out: it normalizes parsed entries or serializes entries for export without encryption or store access.
Import formats
The import service converts each source file into a common entry shape before it reaches the vault. This keeps format rules separate from vault writes and lets one file contain several entry kinds, including logins, notes, cards, identities, SSH keys, environment entries, and API keys.
| Format | Input | Main use |
|---|---|---|
| Bitwarden | JSON | Import or export with Bitwarden-compatible records, passkeys, password history, and custom fields. |
| CXF / FIDO Credential Exchange Format | JSON | Exchange grouped credentials such as passwords, passkeys, TOTP values, API keys, SSH keys, cards, and notes. |
| Generic CSV | CSV | Import or export Rowel's broad entry column set. |
| Browser CSV | CSV | Import Chrome, Safari, or similar browser CSV headers. |
| LastPass CSV | CSV | Import LastPass's CSV shape. |
| KeePass CSV | CSV | Import KeePass's CSV shape. |
An explicit format selection takes priority. Dropped files can use automatic detection based on the name and file content. JSON detection distinguishes CXF from Bitwarden by its top-level structure. CSV detection uses its header names to select a known dialect or the generic reader. src-tauri/…/mod.rs• L254-345
Import preview and commit
The import flow uses a dry run before it changes the vault. The preview parses the file and reports the number of usable rows, skipped rows, duplicate rows, and row-specific errors. A real run writes only after the user accepts the preview.
The process follows this sequence:
- The user chooses or drops a file and selects a format, or asks for automatic detection.
- The native import command reads a bounded file and parses each row.
- The frontend shows the preview and any row errors without changing the vault.
- The commit pass seals accepted entries and writes them as one transaction.
- The command returns the refreshed entry list and progress events update the UI during large imports.
This diagram shows how source data becomes vault data while malformed rows stay visible instead of stopping the whole batch.
flowchart LR
A[Chosen or dropped file] --> B[Format parser]
B --> C[Normalized entries]
B --> D[Row errors]
C --> E[Dry-run report]
E --> F{User commits?}
F -- No --> G[Vault unchanged]
F -- Yes --> H[Duplicate check]
H --> I[Seal accepted entries]
I --> J[One vault transaction]
J --> K[Refreshed entry list]
Rows that fail to parse are skipped and returned with a one-based source row number. A repeated import does not create duplicate entries when the normalized content is identical after bookkeeping fields are ignored. A similar entry with changed secret data remains a real import. Imported dates from the past remain available for sync ordering; invalid or future dates use the current time instead. Unsupported passkeys or TOTP parameters are reported at the source row while the rest of the entry can still import. src-tauri/…/import.rs• L25-27 src-tauri/…/import.rs• L45-70 src-tauri/…/import.rs• L106-205 src-tauri/…/import.rs• L208-264 src-tauri/…/import.rs• L440-450 src-tauri/…/bitwarden.rs• L181-225 src-tauri/…/cxf.rs• L211-228 src-tauri/…/cxf.rs• L377-416
Export formats and data fidelity
Exports unseal the open vault, map entries to a selected exchange format, and send the result to a user-chosen file. They are migration files rather than encrypted backups. The normal export path always uses a native save dialog; an explicit destination is limited to the end-to-end test path.
The three formats preserve different parts of the entry model:
- Bitwarden JSON maps common login, card, identity, SSH, note, passkey, password-history, and favorite fields to Bitwarden fields. Data without a native Bitwarden field uses labeled custom fields.
- CXF JSON maps supported credentials to CXF credential types. Values that have no CXF member use custom fields or notes. Identity and environment entries use note-like representations because CXF has no matching Rowel credential for all of their fields.
- Generic CSV writes a wide Rowel column set. It includes every supported entry kind, common secrets, specialized fields, tags, favorites, and timestamps.
The shared mapping keeps fields such as passphrases, environment data, extra fields, entry dates, and password history available where the target format has no dedicated slot. Some conversions are intentionally one-way. For example, an environment entry or API key may return as a note or login when the target format has no matching type.
CSV output escapes cells that look like spreadsheet formulas. Rowel's version marker lets its own importer reverse that escape without treating a user's leading apostrophe as a formula guard. The marked format also lets older Rowel CSV files read with newer fields absent.
References: src/…/imports.ts• L15-42 src-tauri/…/import.rs• L283-352 src-tauri/…/export.rs• L19-77 src-tauri/…/export.rs• L136-320 src-tauri/…/export.rs• L377-617 src-tauri/…/export.rs• L699-830
Encrypted vault backups
A .rowel file is a complete encrypted snapshot of the vault. It uses the same pack shape as the vault copy used for Drive synchronization, so a local file restore and a remote vault restore follow the same recovery model. The snapshot includes the vault state needed for recovery, including retained deleted records that have not yet been reclaimed.
The backup command asks for the current vault password before it copies the snapshot. The password check confirms that the person requesting the export can open the data being carried away; the vault remains encrypted in the saved file. The frontend calls exportVault, and the native command writes the result with the .rowel extension through the save dialog.
First-run restore accepts a .rowel path and the vault password. The native setup flow reads and validates the pack, creates the local vault, and opens it. If a connected Drive account supplied the pack instead, the same setup path also adopts the selected remote vault and keeps sync configured. A file restore has no remote account to adopt.
This diagram shows the different sources that converge on the same first-run vault adoption boundary.
flowchart LR
A[Open vault] --> B[Password check]
B --> C[Encrypted .rowel snapshot]
C --> D[Local file]
E[Selected Drive pack] --> F[Pack restore]
D --> F
F --> G[Validate and open vault]
G --> H[First-run session]
Opening a .rowel by double-click or by an operating-system file association sends the path through the file:opened event or the one-time startup handoff. The frontend routes it to first-run restore when no vault exists and to the Import settings flow when an unlocked vault is already active. The Import screen does not treat .rowel as a merge file.
References: src/…/backup.ts• L1-10 src/…/vault.ts• L38-42 src/…/setup.ts• L57-64 src/…/pickers.ts• L18-29 src-tauri/…/vault.rs• L128-130 src-tauri/…/vault.rs• L200-262 src-tauri/…/setup.rs• L240-266 src/…/app.ts• L281-299 src/…/events.ts• L58-63
Legacy encrypted merges
The .swftx path supports an older encrypted vault file that is merged into the currently unlocked vault. The source file has its own password and encryption key, which can differ from the open vault's password. Native code decrypts the source, re-seals each entry under the current vault key, and upserts the records by entry identity.
The merge returns a count and a refreshed entry list. The frontend then asks the sync service to publish the new state when sync is configured. A wrong source password leaves the open vault unchanged and keeps the error available for correction.
References: src/…/vault.ts• L27-36 src/…/useImport.ts• L96-115 src-tauri/…/vault.rs• L141-197
File picker boundaries
File access uses two native picker patterns. A path that a command will own as a source or destination can come from the frontend dialog. A path that native code will read and return to the webview uses the Rust-owned picker so the backend can record the user's choice before it reads the file.
| File action | Picker rule | Result |
|---|---|---|
| Backup source | Frontend picker filters .rowel. | The path goes to restore or legacy merge logic. |
| Third-party import source | Frontend picker offers JSON and CSV. | The selected format parser reads the path. |
| Environment source | Native picker accepts any name. | The backend validates the name or env-like contents before returning text. |
| Image source | Native picker filters supported image types. | The backend reads only a path granted for image scanning. |
| Export or backup destination | Native save dialog. | The user selects where plaintext export or encrypted backup is written. |
The native picker grants a purpose to paths used for image or environment reads. A path picked for one purpose cannot be spent on the other. Reads require an open session and are discarded if the vault locks before the read finishes. These rules reduce the chance that a webview path request can turn into an unintended disk read.
References: src/…/pickers.ts• L4-29 src/…/tools.ts• L55-84 src-tauri/…/tools.rs• L16-55 src-tauri/…/tools.rs• L57-83 src-tauri/…/env.rs• L102-128
Environment file recovery
Environment entries use the file body as their secret value and keep the source file name as a hint for later recovery. The ingest path reads the full UTF-8 file without parsing or changing its text. It accepts standard names such as .env, .env.local, and production.env; an oddly named dropped file must instead look like a block of variable assignments.
The backend limits reads to 1 MiB and refuses non-text files. Saving a revealed environment entry is a desktop-only action. It uses the saved name when available and otherwise suggests .env, then writes through a native save dialog.
References: src/…/imports.ts• L44-53 src/…/tools.ts• L55-69 src/…/vault.ts• L44-51 src/…/useIngest.ts• L33-53 src-tauri/…/env.rs• L16-99 src-tauri/…/vault.rs• L264-293
Change checklist
When these files or sections are changed, remember to consider these:
- Keep
ImportFormatandExportFormataligned with native format names and the format detection aliases in src-tauri/…/mod.rs. - Keep the normalized entry mapping, custom-field labels, and reverse import mapping aligned so fields without native target slots survive a round trip.
- Keep passkey and password-history limits aligned with the source adapters, vault model, and export mappings.
- Keep
.rowelnaming aligned across src/…/backup.ts, native backup commands, sync pack layout, and desktop file associations. - Keep the
ImportReportand progress event fields aligned with the native report and event payloads. - Keep the file-picker purpose grants aligned with every command that reads a path back into the webview.
- Treat any change to backup pack structure as a change to both local file restore and Drive restore.
- Keep CSV version markers and formula escaping aligned with the generic CSV reader so old Rowel sheets and literal apostrophes remain readable.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Import file exceeds the native size or entry limit. | The import stops before rows reach the vault. | Native import caps the file at 25 MiB and the parsed batch at 100,000 entries. |
| A source row cannot be parsed. | That row is skipped while other valid rows can continue. | The report returns a one-based row error instead of aborting the batch. |
| The same normalized entry is imported again. | The repeat is not written a second time. | Duplicate checks compare normalized content and ignore source bookkeeping fields. |
| Backup password does not open the source pack. | Restore or legacy merge fails without changing the target vault. | The source is validated before native store writes begin. |
| A future or invalid imported timestamp is accepted as-is. | Sync conflict ordering could be corrupted by untrusted source data. | Imported dates in the future or invalid dates are replaced with the current time. |
| A webview submits an ungranted path for an env or image read. | Native file access is refused. | Rust-owned pickers and path-purpose grants gate the read. |
| An environment file is too large or not UTF-8. | The file is not placed into an environment draft. | The native reader enforces the 1 MiB cap and UTF-8 check. |
| A CSV export contains a formula-like value. | A spreadsheet can treat the value as a formula when it opens the file. | Rowel adds a reversible guard and marks its CSV version. |
| A CXF TOTP uses an unsupported algorithm, period, or digit count. | The login imports without that TOTP credential. | The row report records the TOTP error instead of inventing parameters. |
Key files
| File | Why to read it |
|---|---|
| src/…/imports.ts | Frontend contract for third-party import, export, reports, and environment reads. |
| src/…/vault.ts | Frontend contract for encrypted backup export, legacy merge, and environment file save. |
| src/…/setup.ts | First-run restore contract for local .rowel files and remote packs. |
| src/…/useImport.ts | Frontend flow for picking, previewing, committing, and merging files. |
| src/…/pickers.ts | User-facing backup and migration picker filters. |
| src-tauri/…/import.rs | Native boundary for bounded reads, previews, duplicate checks, sealing, and third-party exports. |
| src-tauri/…/mod.rs | Shared entry model, supported import formats, detection rules, and format adapter contract. |
| src-tauri/…/bitwarden.rs | Bitwarden record mapping, passkey support, password history, and custom fields. |
| src-tauri/…/cxf.rs | CXF credential grouping, passkey and TOTP handling, and partial-row errors. |
| src-tauri/…/export.rs | Bitwarden, CXF, and generic CSV mappings plus CSV safety rules. |
| src-tauri/…/tests.rs | Guarantees for format detection, partial imports, round trips, special credentials, and CSV safety. |
| src-tauri/…/vault.rs | Encrypted .rowel backup creation and legacy .swftx merge behavior. |
| src-tauri/…/setup.rs | First-run file restore and adoption of a recovered vault. |
| src-tauri/…/env.rs | Environment file validation and bounded native reads. |
| src-tauri/…/tools.rs | Native picker ownership and purpose-based path grants. |