# Restore a copy of the data directory (/run/restore-the-data-directory)

Bring back the same instance, keys and sign-ins included, from a snapshot or a stopped copy of its data directory, and settle the work each device kept.



A copy of [the data directory](/run/run-on-a-server#the-data-directory) brings back the same instance, keys and sign-ins included. A [backup](/run/back-up-and-restore) brings back the data into a new instance, and needs only its place.

## Take a copy that's whole [#take-a-copy-thats-whole]

**The copy must be an image of one moment:** a copy taken with the server stopped, or a snapshot, such as a host's disk snapshot or Time Machine, which copies from an APFS snapshot. A file-by-file copy of a running server can hold a database that isn't whole.

Keep the server's secrets with the copy: `marfa.env` from the install folder, or `marfa.secrets` where the server made them, or the two variables your platform holds.

* **With a different `MARFA_KEY_SALT`,** the server starts but refuses every key and app token, and every browser is signed out: sign in as the owner again and make new keys.
* **A different `MARFA_AUTH_SECRET`** also signs everyone out of the browser.
* **Without `marfa.settings.key`,** inside the data directory, which seals the secret settings, each must be set again.

## Settle the work each device kept [#settle-the-work-each-device-kept]

**A device keeps the work the copy lost.** Each app or synced folder that wrote after the copy's moment finds that the server went back, and queues that work again, blocked `server_restored`, so nothing is sent back unasked: you may have restored the copy to undo it.

On each device, send it or drop it:

```bash
marfa device release --reason server_restored
marfa device withdraw <id>
```

A restore from an archive or a backup only adds to what the server holds, and sets off none of this.

The rules behind this page are in the [backing up](https://github.com/withmarfa/marfa/blob/main/conformance/spec/instance.md#backing-up) section of the instance chapter and the [device](https://github.com/withmarfa/marfa/blob/main/conformance/spec/device.md) chapter of the contract.
