9 Restoring: a lost host, or a move to a new one

This also covers a machine you have rebuilt.

  1. On the new host, install Docker and the host tools the Administrator's Guide lists. Unpack the same release, or a later one, into a new directory. Put the original .env and your Compose additions there. Change APP_URL and DOMAIN only if the address is changing. Do not start the stack.

  2. Copy the two backup files from one run to the host.

  3. Restore. The script refuses a database that already holds data:

    ./deploy/restore.sh /var/backups/grc/db-<stamp>.dump /var/backups/grc/uploads-<stamp>.tar.gz
    

    For .age files, also set BACKUP_AGE_IDENTITY=/path/to/key. Compose may warn that the uploads volume was not created by Compose: the script made it, and that's harmless.

    If loading the database fails, it is left empty, so fix the cause and run the same command again. If a later step fails, the database is restored and the same command refuses to run. The script says so: fix the cause, run ./deploy/restore.sh --files-only with the archive, and carry on. Don't remove the database volume to get past it.

  4. Build the image and run migrate, with web and the worker off. migrate brings the schema up to this release, and creates the application role:

    docker compose build
    docker compose run --rm migrate
    
  5. Follow "After any restore", below.