Documentation menu

Operating the server

Updates

Memex updates itself: it replaces its own program file with the new version and restarts. No package manager is involved. You choose how much of that happens without you, with one of three modes.

The three modes

ModeBehaviour
notify (default)Memex checks for new versions and tells administrators once per version. You decide when to install, from the app or with memex update.
autoNew versions are installed as soon as they are seen.
manualMemex still checks, so the app can show what is available, but never notifies and never installs by itself.

Change the mode in the app under Administration → Updates, or on the server:

sudo memex update --mode notify
sudo memex config set update_mode auto

The check runs about a minute after the server starts and then every six hours. It reads the latest release of the project from the GitHub API. Nothing about your instance is sent other than what any HTTP request reveals: its IP address and a memex/<version> user agent.

Updating by hand

sudo memex update            # shows installed/latest, asks, installs, restarts the service
sudo memex update --check    # only shows whether a new version exists
sudo memex update --yes      # no question (scripts)

What an update does

  1. Fetches the release description and compares versions. Nothing happens unless the published version is strictly newer.
  2. Downloads the archive for the machine and its signature.
  3. Verifies the signature (minisign, Ed25519) against the public key compiled into the running binary. An archive that is unsigned, signed with another key or modified is rejected and nothing is changed.
  4. Takes a full backup to backups/pre-update-<current version>.tar.gz in the data directory; the three most recent are kept. If the backup fails, the update is not installed.
  5. Unpacks the new program and runs it with --version: it must start and report exactly the expected version.
  6. Keeps the current program as memex.previous and renames the new one over it.
  7. Restarts. Database migrations, if any, run automatically at start.

Clients are disconnected for a few seconds. With a quick tunnel, the restart also changes the public address: prefer notify or manual in that mode, or use a permanent tunnel.

Rolling back

If the new version fails to start, Memex goes back by itself: when the service has been started a third time without the new version getting as far as serving requests, the previous program is put back and started instead. By hand:

sudo memex update --rollback

This swaps the program with memex.previous and restarts the service; running it again swaps back. Rolling back the program does not roll back the database. Most updates do not change the database schema; if the newer version had migrated it, the older program refuses to start and says so. In that case also restore the automatic backup:

sudo memex restore /var/lib/memex/backups/pre-update-<version>.tar.gz

Anything written between the update and the rollback is not in that backup; the data in place before the restore is kept aside, so nothing is destroyed.

When self-update is not possible

If the directory of the program is not writable by the service (Memex was not installed with the installer), the app and memex update say so, and the auto mode behaves like notify. Run sudo memex update, or run the installer again, which replaces the binary and keeps data and configuration:

curl -fsSL https://raw.githubusercontent.com/mlafraise/memex/main/install.sh | MEMEX_NO_RUN=1 sh
sudo systemctl restart memex

Reference: updates.md. The desktop app has its own updater; see Desktop app.