Skip to content
SEUNGWOO CHOI edited this page Nov 19, 2026 · 10 revisions

Backup and recovery

English · 한국어

Keep the encrypted backup file and that vault's recovery code separately. Email sign-in alone cannot decrypt a vault, and browser storage does not guarantee permanent retention. New exports use authenticated backup format v2; legacy v1 imports have the restrictions below.

Export and import

Account prepares backup and diagnostics independently on open. Wait until the relevant controls are enabled; a failed module load offers its own retry and preserves the editor. Ready backup/diagnostic actions can run offline, and a completely installed production Service Worker also supports first opening Account offline. See Account loading and PWA readiness. Home recovery-code creation remains immediately available. Server recovery/sync still needs a connection.

  1. Unlock the vault and create or locate its recovery code.
  2. Use encrypted backup download in Account to save miroven-YYYY-MM-DD.miroven-backup.json.
  3. On an empty vault, enter the same recovery code and import the backup.
  4. Keep the original file until entries, photos, pending operations, and conflicts have been checked.

If PIN locking is configured, remove it in Account settings using the current PIN before creating the first recovery code. Unlocking the vault with the PIN is not enough. After creating and saving the recovery code, set up PIN locking again. Recovery-code creation rejects a configured PIN without changing vault data, so the PIN envelope cannot retain the previous key when entries are re-encrypted.

Import does not overwrite existing entries, envelopes, Outbox, or cursors. Export rejects a locked vault, missing recoverable envelope, old-format records, or invalid ciphertext. Backups allow at most 100 MiB and 100,000 entries/Outbox operations each, using v3 encrypted entries. Text, photos, and keys are encrypted, but IDs, revisions, times, sizes, and sync state can be visible in outer JSON. Do not edit it; see format details.

Clearing the local vault cancels any pending backup import, including imports started in another tab. To restore afterward, enter the recovery code again and choose the backup file. The app keeps a local reset token in IndexedDB to enforce this across tabs. Backups and synchronization exclude the token.

The backup contains this device's entries, photos, and Outbox. It excludes remote changes not yet received, recovery codes, drafts, and recent searches. Export sets the API cursor to zero; restore establishes a fresh API/account binding and reconciles a full snapshot without reusing the old signed cursor.

Another device or address

For already-synced records, sign in to the same API account and unlock with the recovery code. To move unsent changes too, use a file backup. Different domains or ports have separate IndexedDB; export at the old origin and import into an empty vault at the new origin. Local reset and server deletion are separate operations.

Recovery-code spaces/hyphens are ignored. The code needs 40 secret characters plus 2 checksum characters. Mismatch or corruption can indicate another vault's code or failed ciphertext validation. Confirm restoration before deleting originals or codes.

Diagnostics

The lightweight activity recorder is included in journal startup. Report generation and download code (app/lib/diagnostics.ts) is loaded on Account open and at the download handler; it is excluded from startup's eager dependency path. A loading/error state disables only its download and offers retry, independently of backup readiness.

Account diagnostics JSON includes app version, time, browser, language, theme, connectivity, entry count, count of entries with photos, pending-operation/conflict counts, PIN/lock status, and storage estimates. entriesWithImageCount counts each entry with at least one legacy image or current images[] photo once, not the total number of photos. Entry-derived counts are zero while the vault is locked. It excludes entry text, photos, recovery codes, and keys. Metadata can still help identify someone: inspect it before sharing.

Diagnostics schema version 2 retains the previous fields and adds activity, runtime, and collectionStatus. The lightweight recorder is eager; report generation and download remain lazy. activity keeps the latest 200 start/completion events in this tab's memory, with sequence, local operation number, elapsed time, duration and success/failure/cancellation. Events cover journal operations, image processing/loading, PIN, backup/recovery, sync/conflict resolution, API route categories, Account module loading, connectivity, visibility, unhandled errors and Service Worker events. It never stores inputs, entry/account/blob identifiers, filenames, URLs, headers, bodies, error messages or stacks; errors use fixed type/code allowlists. No activity is persisted or automatically uploaded.

runtime includes viewport/scale, time zone, browser/standalone mode, API configuration presence (without its address), known authentication/sync status and Service Worker support/control. Unknown authentication/sync state is null. collectionStatus distinguishes ok, failed, unsupported, and locked: legacy zero/false/null fallbacks are not evidence that a failed measurement succeeded. A measured zero storage estimate is "0.0".

Reload, pagehide, vault lock, explicit sign-in/sign-out, account deletion, subsequent discovered identity changes and local reset erase prior activity. Explicit sign-in clears history even for the same account. Completions started before a reset cannot refill it. A report/download crossing that boundary is cancelled. Counts remain zero when locked; no migration of vault, API or backup data is needed.

The first session lookup preserves startup history and pending completions whether it discovers a signed-in or signed-out session. Later same-account refreshes also preserve them. A network failure during the initial lookup leaves authentication unresolved (runtime.authenticated: null); a successful retry still preserves startup history. Once a session has been resolved, discovering a different identity or session expiry clears history.

On a failure, keep the tab open and export from Account before reloading, locking, signing in or signing out. Inspect metadata before sharing, then reproduce with synthetic data on the reported browser/version using the event order. This is a diagnostic aid, not a recording that can replay personal data; crashes or unavailable Account UI have no separate export path.

Authenticated backup v2 and migration

New exports use miroven-encrypted-backup, version 2. The v1 fields remain, with authentication: {"algorithm":"hmac-sha256","tag":"<base64>"} added. HMAC-SHA-256 authenticates the entire root JSON object excluding only its authentication property: entries, array order, Outbox deletions, revisions, statuses, export time, cursor, format/version, and vault envelope. Canonical bytes are UTF-8 of compact ECMAScript JSON.stringify with object keys recursively sorted using JavaScript's default string sort; arrays retain their order. JSON whitespace and object property order do not affect verification. This is an integrity layer, not whole-file encryption or proof of freshness.

Derive a 256-bit HMAC key with HKDF-SHA-256 from the raw 32-byte vault key, the envelope's 16-byte recoverySalt, and UTF-8 info private-journal:backup-auth:v2. Encode the 32-byte tag as canonical padded standard Base64. The nonextractable derived key is separate from entry and recovery keys; erase the temporary exported vault-key buffer after derivation. Unwrap the vault envelope with the recovery code and verify the complete manifest before normalizing operations or writing any vault data. Continue the existing per-record checks. The recovery code is never written into the file.

Compatibility:

  • A v2 backup requires an updated client; v1-only clients reject it. Existing IndexedDB data, entry/sync ciphertext, AAD, and recovery codes are unchanged. No API migration is needed.
  • A trusted v1 file without deletion operations can still be imported, including encrypted pending/conflicting upserts and photos. Re-export it from the updated client to create v2. v1 metadata remains unauthenticated; migration cannot retroactively establish its integrity.
  • Reject a v1 file containing any pending or conflicting delete before writing data. Keep the file intact. Use the original device with the updated app to export an authenticated backup. If that device is unavailable, retain the original file and use a separately reviewed recovery process; do not remove operations or downgrade the file by hand.
  • Stripping the v2 tag and changing its version to v1 cannot enable unsigned deletion import. Legitimate v2 deletions and conflict status round-trip unchanged.

Keep originals until restoration and synchronization are verified.

Implementation compatibility

The backup code split preserves the asynchronous createEncryptedBackup() and importEncryptedBackup(json, recoveryCode) functions from app/lib/local-vault.ts; they dynamically import vault/backup.ts. Envelope lookup lives in vault/envelope.ts. Shared LegacyBackupDeletionError and RecoveryPinLockError classes live in vault/operation-errors.ts, with existing facade/legacy paths re-exporting the same identities for instanceof checks. The PIN refusal still exposes code: "PIN_LOCK_CONFIGURED". These loading changes do not modify the v2 backup contract, legacy rejection rules, encryption/AAD, database identifiers, or pending/conflict preservation, and require no migration.

Clone this wiki locally