# Recovery, backup, and migration (https://docs.open-e2ee.dev/build/recovery-backup-migration.md)

- Status: stable
- Applies to: 15.0.0
- Platforms: Expo · Browser · Node
- Prereqs: A working client from Start → Quickstart
- Reading time: 15 min

"If the user loses their phone, is their data gone?"

Most teams have never had to answer this, because the server always had a copy.
Under end-to-end encryption it becomes a product decision with no correct default.
This page gives you three named positions, states what each one costs, and points
at the operations that implement them. It does not pick one, because the SDK does
not pick one either.

## What the SDK moves, and what it does not [#what-the-sdk-moves-and-what-it-does-not]

Two operations exist, and neither moves sessions or message history. The managed device
link adds a device to the account. In the two-device link, a new device with an empty
store joins, and device 1 approves it. The one-process link,
`linkHostedSignalProtocolRelayDevice()`, joins a device that already holds the account identity.
Transfer to replacement
hardware moves the long-lived account identity and the device metadata in an encrypted
backup. The new device creates fresh prekeys and sessions after the restore:

```ts
import {
  prepareNewDeviceTransfer,
  prepareOldDeviceTransferWithBackup,
} from '@open-e2ee/signal-protocol-sdk/device';

// New device: show the QR code that the old device scans.
const receiving = await prepareNewDeviceTransfer({ platform: 'android' });
await appQr.show(receiving.qrCode);

// Old device: read the account identity from its backup storage.
const sending = await prepareOldDeviceTransferWithBackup(backupStorage, { platform: 'ios' });
const backup = await sending.getBackup();
```

This path requires **the old device**. Device-to-device transfer supports an
upgrade, not recovery after loss. A phone in a canal cannot participate.

Your application must build recovery for a device that never held the state. This
process restores from a source other than the old device. You decide where the
material lives, who can access it, and which authentication it requires.

> **Tradeoff — Device-to-device transfer or a stored backup**
>
> Transfer needs both devices present and working. Nothing durable is left behind,
> so an attacker has no stored copy to target. The user also has no stored copy.
> Transfer supports upgrades but not device loss.
>
> A stored backup supports device loss, but it exists continuously. It is a durable
> artifact in a known location. A user-held secret or your infrastructure protects
> it. If you ship transfer and backup, you accept all stored-backup costs.

## Why recovery is structurally hard [#why-recovery-is-structurally-hard]

Engineering cannot remove this conflict. 1Password states it directly:

> "Recovery mechanisms are inherently weak points in maintaining the secrecy of data."

A recovery path for a user who lost all devices can also become an attack path.

Signal Messenger uses a 64-character recovery key:

> "Signal cannot recover, reset, or bypass"

If a user loses the key, Signal cannot recover it. Earlier, Signal used secure
enclaves to let a PIN open Secure Value Recovery material. That design received
significant criticism. Matthew Green described the expansion risk:

> "Nobody is going to engineer something as complex as Signal's SVR just to store
> contact lists. Once you have a hammer like SVR, you're going to want to use it to
> knock down other nails."

The mechanism creates risk regardless of its first use.

The industry has not settled this question. Meta shipped Labyrinth 1.1 in May 2026,
two and a half years after Messenger enabled end-to-end encryption by default. The
change sends messages to encrypted backup:

> "as they're sent, rather than waiting for your device to come back online."

Meta continues to change how messages survive a lost phone.

## Three profiles [#three-profiles]

Select one profile deliberately. Each profile protects different properties.

### Profile: `business-archive` [#profile-business-archive]

A server-confidential business archive preserves history after device loss, staff
turnover, and hardware replacement. Its purpose is continuity across devices.

**Protects:** message content against relay compromise, infrastructure breach, and
bulk disclosure because the storage layer holds ciphertext. Backups mean a lost laptop is
an inconvenience rather than a data-loss event.

**Gives up:** coercion resistance. An authority can compel use of a durable
recovery path. An attacker can socially engineer it, and an insider can misuse it.
These attacks depend on access to the authentication in front of the path. This
profile also gives up "nothing to hand over" as a posture. You must monitor and
rate-limit this permanent, high-value attack surface.

**Suits:** internal business communication, regulated professional services where
records must persist, and any product where losing history is worse than the extra
exposure.

**You implement:** an encrypted backup artifact and its key hierarchy. Add strong
recovery authentication and audit every recovery attempt, including failures.
Define how operators detect that "an administrator triggered a recovery."

### Profile: `high-risk-messaging` [#profile-high-risk-messaging]

This profile limits recoverable history by design. A lost device means lost
history.

**Protects:** users against compulsion, seizure, and later access. An adversary
cannot access a durable artifact. Current device content bounds retention. This
design also reduces the content that an authority can compel your organization to
produce.

**Gives up:** continuity, and it generates support load. Users will lose history
and some of them will be angry, because every other application they use restores
silently. Expect this to be your most common support category.

**Suits:** journalism, activism, legal-privileged and source-protection contexts,
and consumer products whose promise is explicitly ephemerality.

**You implement:** define and enforce a retention policy. During onboarding, tell
users that device loss removes history. Provide export flows for users who still
have the device and need a record.

### Profile: `collaboration-default` [#profile-collaboration-default]

A middle position, and explicitly a compromise. It balances offline work,
recoverability, and membership change for teams that are neither an archive nor a
threat-model product.

**Protects:** recent working context. A replaced laptop recovers enough to keep
working, and offline devices reconcile without a full history refetch.

**Gives up:** it does not guarantee that an eighteen-month-old message survives.
Therefore, it cannot be the system of record. It also retains a recovery path, so
it resists coercion less than `high-risk-messaging`. It provides
part of each property, not all of either property.

**Suits:** team collaboration tools, product and engineering workspaces, customer
communication where a separate system already holds the durable record.

**You implement:** define a retention period and enforce expiry. Limit recovery to
that period. Clearly separate "your messaging history" from "your system of
record" before an audit.

> **Tradeoff — Recoverable history against coercion resistance**
>
> The `collaboration-default` profile sits between the two other profiles. It does
> not remove their conflict. An attacker can use a mechanism that supports recovery
> after total device loss. An authority can also compel the user to use it. A design
> that prevents all recovery also prevents recovery by the legitimate user.
>
> The SDK does not silently choose this for your application. There is no default
> backup, no automatic archive, and no hidden escrow. If your product recovers
> history, it is because you built the path.

## Operations you have [#operations-you-have]

```ts
await signal.clearAllData();
```

`clearAllData()` wipes local protocol state. It completes only the local part of
an account reset. Account reset must clear the device-ID cache,
platform secret storage, and protocol store as one product-level lifecycle. Doing
one and not the others leaves a device with a cached identity claim it can no
longer back.

`forceCompleteKeyReset()` regenerates keys with fresh IDs and republishes them. The
SDK marks it for development and debugging only. Treat it as a break-glass tool,
not part of a user recovery flow.

`rotateAccountIdentity(expectedCurrentCommitment, identityType)` is the deliberate
identity rotation, guarded by a caller-authenticated compare-and-swap against the
32-byte commitment you expect to be current. Normal sync and the managed device
link never call it. Rotating an account identity is visible to every peer
as an identity change. See
[Identity changes and safety numbers](https://docs.open-e2ee.dev/build/identity-change-safety-numbers.md).
This recovery operation has a visible social cost.

> **Failure mode — Erasing the old device too early**
>
> The application owns transport selection, peer confirmation, progress UI,
> interruption recovery, and wiping old-device state after a successful replacement.
> Do not erase the old device before the new device validates and durably restores
> the backup.
>
> This failure can appear after a successful transfer. The user resets the old
> device, but the new device contains only a partial restore. No server copy can
> complete the restore. Require the new device to confirm a durable read before you
> erase the old device. Do not use only the transfer call's return value.

> **Tradeoff — Backup keys the user holds against keys your service holds**
>
> A passphrase or long recovery code gives the user custody of the key. Your service
> cannot open the backup. An authority also cannot compel your service to open it.
> However, the service cannot recover a forgotten code.
>
> A service-assisted key prevents that loss but creates another risk. Attackers can
> target the component that your service holds. Its existence also changes the
> answer to "can you decrypt this?" Green's warning applies here. A backup escrow
> mechanism can expand to protect additional data.

## Deletion is not remote deletion [#deletion-is-not-remote-deletion]

Encryption does not give you a delete button on someone else's device. After
another participant gets a decrypted copy or stores it in a backup,
cryptographic confidentiality creates no remote deletion guarantee. You can stop
serving an envelope. You cannot reach into a peer's local store, and any product
copy suggesting otherwise is a promise you cannot keep.

The same applies to your own backups. A message deleted from a thread today is
still in an archive written yesterday, unless you built the process that reconciles
them.

**Opacity ledger**

| Artifact | Stays on device | Sent to relay | In object store | Visible as metadata |
|---|---|---|---|---|
| `prepareNewDeviceTransfer()` `qrCode` | yes | no | no | no |
| Backup from `sending.getBackup()` | yes | encrypted, if routed that way | optional, encrypted | size and write time |
| Backup encryption key | yes, or user-held | no | no | no |
| `identityKeyPair` private half | yes | no | no | no |
| `identityKeyPair` public half | yes | yes | no | yes |
| Session records (`version: 4`) | yes | no | no | no |
| Prekeys (private halves) | yes | no | no | no |
| Prekeys (public halves) | yes | yes | no | count and consumption rate |
| Decrypted message rows (app-owned) | yes | no | no | no |
| `rotateAccountIdentity()` commitment | yes | yes | no | yes — the relay sequences the swap |
| Recovery attempt audit records (app-owned) | yes | no | no | no |

The SDK versions session records. It rejects and resets older formats instead of
migrating them. A backup from an older build can therefore contain an incompatible
session. Plan for the SDK to discard and recreate that session instead of resuming
it.

## This surfaces after launch [#this-surfaces-after-launch]

Device loss often occurs after a beta. Replacement cycles, water damage, and theft
operate over months. The recovery question can therefore arrive after you set the
architecture. Changing profiles then requires migration between incompatible user
expectations.

Decide before launch, and write the chosen profile name down. When someone later
proposes a feature that quietly moves you between profiles, that written decision
is what makes the conversation possible.

> **Not covered — Legal hold and retention**
>
> Your jurisdiction and industry determine whether your organization must retain or
> produce messages. This legal requirement affects your selected profile. This page
> does not provide legal guidance. See
> [Licensing](https://docs.open-e2ee.dev/licensing.md) for the licensing side,
> and take the retention question to counsel.

The SDK is `15.0.x`. Public APIs and persisted formats follow semantic versioning.

## Next [#next]

- [Multi-device](https://docs.open-e2ee.dev/build/multi-device.md): link a device without carrying history
- [Deletion and revocation](https://docs.open-e2ee.dev/operate/deletion-revocation.md): understand deletion operations
- [Threat model](https://docs.open-e2ee.dev/learn/threat-model.md): select one of the three profiles
- [Production checklist](https://docs.open-e2ee.dev/operate/production-checklist.md): verify this decision before launch
