Skip to main content

Back up, restore and upgrade

By the end of this guide you have backed up a home folder and a relay, restored both, and checked that the restored copies are the same ones.

This guide is for macOS and Linux. In the expected output, text in angle brackets, such as <alice address>, stands for a value that is different on every machine.

Before you start​

Interlinked built and on your PATH, as in Install.

Back up and restore a home folder​

A home folder (~/.interlinked by default) holds your identities, with their keys, and every room you belong to. Copying it is the whole backup. Because it holds your keys, treat the copy like an SSH key: keep it where only you can read it, and do not put it on shared or synchronised storage unless it is encrypted. cp -p keeps the permissions, so the copy stays readable only by you.

Make a home with a room and a message, copy it, delete it, and restore it:

il init alice
{"address": "<alice address>", "home": "~/.interlinked", "launcher": "~/.interlinked/bin/il", "name": "alice", "project": "<project folder>"}
il init bob
{"address": "<bob address>", "home": "~/.interlinked", "launcher": "~/.interlinked/bin/il", "name": "bob", "project": "<project folder>"}
il --as alice room create team --no-e2ee
{"direct": false, "e2ee": false, "history": "shared", "invited": {}, "join": "invite", "link": "il://local/<room link id>?invite=<invite token>", "members": {"alice (<alice:8>)": "owner"}, "name": "team", "room": "<room id>"}
il --as alice room invite team bob
{"direct": false, "e2ee": false, "history": "shared", "invited": {"bob (<bob:8>)": "member"}, "join": "invite", "members": {"alice (<alice:8>)": "owner"}, "name": "team", "room": "<room id>"}
il --as bob join team
{"detail": "joined", "findings": {"count":0,"findings":[],"omitted":0}, "joined": true, "name": "team", "role": "member", "room": "<room id>", "state": "member"}
il --as alice send team 'Build is green'
Sent: stored locally; 1 recipient(s) will get it when they next read
cp -Rp ~/.interlinked ~/interlinked-backup
rm -rf ~/.interlinked
cp -Rp ~/interlinked-backup ~/.interlinked
il doctor
(shortened: fields not discussed here are left out)
{"ok": true}
il --as bob read
from alice (<alice:8>): Build is green

After the restore, il doctor reports "ok": true and bob still reads the message that was in the home. Make the copy while no il command or il serve is running, so that the folder does not change while you copy it. A backup holds what existed when you made it, so entries written afterwards are not in it. Test a restore before you rely on a backup.

Back up and restore a relay​

A relay keeps its state in two folders: the store, and the TLS certificate and key (Run a relay on your machine with TLS). A copy is only safe when the relay is not writing, so stop the relay first. This part builds a relay with one room, and stops it:

il-relay serve --store-dir relay-store --host 127.0.0.1 --port 7000 --tls --tls-dir relay-tls
{"address":"il://127.0.0.1:7000","cert_sha256":"<id-1>","directory":"<address>","impl":"rust","port":7000,"pub":"<id-2>","tls":true}
export A=$HOME/il-alice
il --home $A config set relay.tls on
{"name":"relay.tls","value":"on","source":"config.toml"}
il --home $A init dana --relay 127.0.0.1:7000
{"address": "<dana address>", "home": "$A", "launcher": "$A/bin/il", "name": "dana", "project": "<project folder>", "rooms_found": 1}
il --home $A room create team --relay 127.0.0.1:7000
(shortened: fields not discussed here are left out)
{"name": "team", "relay": "at the relay"}
# stop the relay with Control-C in its terminal

Copy both folders, delete the originals, and restore from the copies:

cp -Rp relay-store relay-store.backup && cp -Rp relay-tls relay-tls.backup
rm -rf relay-store relay-tls && cp -Rp relay-store.backup relay-store && cp -Rp relay-tls.backup relay-tls

Start the restored relay and check it:

il-relay serve --store-dir relay-store --host 127.0.0.1 --port 7000 --tls --tls-dir relay-tls
{"address":"il://127.0.0.1:7000","cert_sha256":"<id-1>","directory":"<address>","impl":"rust","port":7000,"pub":"<id-2>","tls":true}
il relay status 127.0.0.1:7000 --tls
(shortened: fields not discussed here are left out)
{"rooms": 2}
cat relay-store/FORMAT
il-store 1

Compare the two ready lines: the relay's pub and its cert_sha256 are the same before and after, so this is the same relay, and the room is still there ("rooms": 2, the room and the relay's own directory). il-store 1 is the store's format marker; keep it in mind for the next section.

Never run two independent public relays with the same key and different stores: clients would find two relays that claim to be one.

Upgrade a relay​

Upgrade only after you have made and tested a backup as above.

  1. Stop the relay.
  2. Take the backup and check the format marker (cat relay-store/FORMAT, as above).
  3. Build the new version and put its il-relay on your PATH, as in Install.
  4. Start it with the same options. A settings file that has a key the new version does not know is refused at startup, before the store is opened; fix the file, or put the old binary back.
  5. Run the check from the restart step, compare pub with the one you recorded, and send and read a message before you call the upgrade done.

Keep the old binary and the backup until then. To roll back, restore the backup and start the old binary.

Next​

Use the Python client shows how to drive Interlinked from a program.