Skip to Content
PAPAMO / DOCS

Sync between archives

Copy a self-hosted archive's encrypted messages to a second computer, or into your own database through a sync webhook.

For an off-site copy without running a second server, connect to papamo.dev instead.

Copy to a second computer

Pick one computer as the receiver. Phones keep sending to the original archive, which keeps working when the receiver is offline.

  1. Give the receiver an HTTPS address the sender can reach, allowing requests up to 2 MiB on /internal/sync/.

  2. On the receiver, create a pairing file with a name for this source, such as home, and move it privately to the sender:

    psms sync pair --source home --public-url https://YOUR-RECEIVER --output home.pairing.json
  3. On the sender, run psms sync connect home.pairing.json, then restart both (psms stop, then psms init).

  4. psms sync status on the sender shows how many messages are waiting. The first sync includes everything already stored.

  5. To read the copy, set PSMS_REPLICA_READ_TOKEN (32+ characters) on the receiver, restart it and call GET /v1/replicas/home/messages with that token.

Stars and deletions follow the source. For several computers, pair each with its own source name. To revoke one, remove its entry from the receiver's ARCHIVE.sync-peers folder and restart.

When data moves

Choose how often in Settings → Sync timing: the default (every six hours), hourly, every six or twelve hours, or daily. PSMS_SYNC_INTERVAL_SECONDS sets the default.

pSMS waits until both computers have at least 192 MiB free and aren't busy, then sends batches of eight messages a second apart. Failed attempts retry after five minutes. Several edits to one message collapse into its latest state, and a late retry can never undo a newer change or bring back a deleted message. Keep separate backups if you need to go back in time.

Sync into your own database

Point the sync at your own HTTPS endpoint to store encrypted records in any database.

  1. Run psms sync pair --source home --public-url https://YOUR-RECEIVER --output home.pairing.json on a trusted computer. Give your handler the bearer credential and source name from the file.
  2. Implement POST /internal/sync/home. Check the bearer credential before accepting anything.
  3. On the sending computer, run psms sync connect home.pairing.json and restart pSMS.

Each request is a JSON array of changes:

[
  { "revision": 41, "id": "33f25af6-8774-4d98-b5bf-d73545644319",
    "snapshot": { "sender": "papamo:encrypted:v1", "body": "…", "contact_id": "9f2c…", "archived_at": 1795700000, "starred": false } },
  { "revision": 42, "id": "8d1e…", "snapshot": null }
]
  • Key each record by (source, id). Apply a change only if its revision is newer than the one you have.
  • sender is the encryption marker and body the sealed message; the real sender is inside it.
  • "snapshot": null means the message was deleted. Keep the revision with the deletion.
  • Once the whole batch is saved, return 200 with the last revision as a bare JSON number, such as 42. Anything else is retried, and retried batches should get the same answer.

Changes arrive on the sync schedule and several edits may arrive as one. For new messages right away, use webhooks.