Backup & Restore
Backup and Restore
Section titled “Backup and Restore”All vault data lives in IndexedDB inside the user’s browser. If the user clears site data, switches browsers, or loses their device, the data is gone. Backups are the only safety net.
Backup Format
Section titled “Backup Format”The export produces a single .json file named
macadam_vault_backup_YYYY-MM-DD.json with this structure:
{ "timestamp": "2026-04-26T12:00:00.000Z", "app": "Macadam", "version": 1, "data": { "weekly_earnings": [ ... ], "expenses": [ ... ], "expense_categories": [ ... ], "settings": [ ... ] }}appis always"Macadam". Used for validation on import.versiontracks the schema version at time of export.datacontains the raw arrays from each Dexie store, including auto-generatedidfields.
Export Flow
Section titled “Export Flow”- User clicks Generate & Download Backup on the Settings page.
vault_backup.jsreads all four stores viatoArray().- The result is serialized to a formatted JSON string.
- A
Blobis created and a temporary<a>element triggers the download.
No network requests are made. The entire operation is local.
Import Flow
Section titled “Import Flow”- User selects a
.jsonfile via the file input on the Settings page. - The Restore Vault Data button becomes enabled.
- On click,
FileReader.readAsText()parses the file. - The
appfield is checked — if it is not"Macadam", the import is rejected. - A
confirm()dialog warns the user that existing records with the same IDs will be overwritten. - Data is merged using
bulkPut()(upsert semantics):weekly_earnings— bulk put by ID.expenses— bulk put by ID.expense_categories— IDs are stripped and each category is inserted individually. If a category name already exists (unique constraint), the error is silently caught.settings— bulk put by key.
- The page reloads to reflect the imported data.
What “Merge” Means
Section titled “What “Merge” Means”bulkPut performs an upsert: if a record with the same primary key exists,
it is overwritten. If it does not exist, it is inserted. This means:
- Importing a backup onto an empty vault restores everything.
- Importing onto an existing vault overwrites records that share the same
idand adds new ones. - Records in the current vault that are not in the backup file are left untouched.
There is no “wipe and replace” option at this time.