Sync two databases on the same machine
Sync two databases on the same machine
Section titled “Sync two databases on the same machine”This tutorial shows how to synchronize two memory databases on the same host, or on a shared filesystem, without a relay. This is useful for local backups, shared project stores, or testing sync before moving to a relay.
Prerequisites
Section titled “Prerequisites”od3sa-memoryinstalled.- Two database paths. By default memory uses
~/.memory/default.db. - Both databases are readable and writable by the user running the command.
1. Create or identify the two databases
Section titled “1. Create or identify the two databases”If you do not have a second database yet, memory will create one when it is first opened. For this tutorial we will use:
~/.memory/default.db— the primary store./mnt/shared/peer.db— the peer store (this can be any absolute path).
Make sure the peer database’s parent directory exists:
mkdir -p /mnt/shared2. Run a direct one-shot sync
Section titled “2. Run a direct one-shot sync”The sync command performs a bidirectional merge of delta logs between the local database and a peer database.
od3sa-memory --db ~/.memory/default.db \ sync --peer-db /mnt/shared/peer.db --confirmThe first time you run this, memory will create the peer database if it does not exist and exchange identity information. The --confirm flag is required because the command pushes data to the peer.
To preview what would happen without writing anything, add --dry-run:
od3sa-memory --db ~/.memory/default.db \ sync --peer-db /mnt/shared/peer.db --dry-run3. Pair the databases for repeated sync (optional)
Section titled “3. Pair the databases for repeated sync (optional)”If you plan to sync the same two databases regularly, pair them once with SPAKE2 so each store pins the other’s public key.
First, create a password file with restricted permissions:
install -m 0600 /dev/null ~/.memory/pairing-password.txtecho "shared-secret-at-least-10-chars" > ~/.memory/pairing-password.txtThen pair:
od3sa-memory --db ~/.memory/default.db \ pair-device \ --peer-db /mnt/shared/peer.db \ --account-id your-account \ --password-file ~/.memory/pairing-password.txt \ --confirmUse the same --account-id on both stores and choose a strong password (at least 10 characters). After pairing, subsequent sync commands can optionally verify the peer by its pinned key.
To preview the pairing without writing peer records, add --dry-run.
4. Verify the sync
Section titled “4. Verify the sync”-
Store a memory in the primary database.
-
Run the
synccommand again. -
Search the peer database for the same memory:
Terminal window od3sa-memory --db /mnt/shared/peer.db search "your memory content"
Or check the peer count through health on either database:
od3sa-memory --db ~/.memory/default.db healthExpected output
Section titled “Expected output”od3sa-memory syncexits 0 and reports the number of deltas exchanged.- A memory stored in the primary database is searchable in the peer database after sync.
memory_healthshows a non-zeropeer_countafter pairing.
Using the MCP tool
Section titled “Using the MCP tool”If your agent is connected through MCP, you can also call memory_sync:
{ "peer_db_path": "/mnt/shared/peer.db", "confirm": true}And memory_pair_device for pairing:
{ "peer_db_path": "/mnt/shared/peer.db", "account_id": "your-account", "password_file": "~/.memory/pairing-password.txt", "confirm": true}Note: The password_file must have 0600 or 0400 permissions.
Troubleshooting
Section titled “Troubleshooting”- Peer database is not writable — ensure the user owns the peer database path and its parent directory.
- Identity mismatch — if the peer database was previously paired with a different account, run
pair-deviceagain or use a fresh peer database. - Deltas not propagating — both databases must use the same sync schema version. Run
od3sa-memory healthand check theversionandsyncfields.