# Install Mail Safehouse runs as a small set of Docker containers on one Linux server. The installer sets everything up on **Ubuntu 26.04 LTS** (24.04 also works) with one command. :::{admonition} Beta :class: warning Mail Safehouse is in beta. Test it on a server you can rebuild, and keep your current backup running until you have restored from Mail Safehouse yourself. ::: ## What you need - **A server running Ubuntu 26.04 LTS**, amd64 or arm64, that you can reach from your network. A **dedicated server is recommended**: it holds a copy of your whole tenant. It can share a server with other containers if it has to. - **2 CPU cores and 4 GB of memory** for a small tenant (about 10 users). - **Disk space** for your backups: roughly the size of the mailboxes and OneDrives you protect, plus room to grow. Backups are compressed and deduplicated, so this is an upper bound. - **A DNS name** for the server (for example `backup.example.com`) that resolves on your network, or else a **fixed IP address**. The web UI's certificate is for that name or address, so use it to open the web UI. - **Outbound HTTPS** to Microsoft 365 (`graph.microsoft.com`, `login.microsoftonline.com`, `outlook.office365.com`) and to GitHub and Docker Hub while installing. - A **Global Administrator** of your Microsoft 365 tenant for one sign-in during setup. ## Run the installer Sign in to the server as a user who can use `sudo`, and run: ```bash curl -fsSL https://mailsafehouse.com/install.sh | bash ``` The installer first **checks the server and shows its plan**; nothing is installed until you agree. It: 1. Checks the Ubuntu version, memory and disk space. 2. Checks Docker (see [Docker](#docker) below) and offers to install it if it is missing. 3. Checks that **port 8443** is free. If something else uses it, it shows what, and asks for another port. 4. Asks for the server's DNS name or IP address. It suggests the DNS name if it resolves on the network, otherwise the server's IP address. 5. Notes any other containers already running on the server. 6. Shows the plan, and asks before changing anything. It then downloads Mail Safehouse into **`/opt/mailsafehouse`**, creates its settings and encryption key, builds the application image (several minutes the first time) and starts it. At the end it prints the web address and a **setup token**. The script is [`install.sh`](https://github.com/crimpac/mailsafehouse/blob/main/install.sh) in the repository, published here on every change. Prefer to read it first? Download it, read it, then run it: ```bash curl -fsSLO https://mailsafehouse.com/install.sh less install.sh bash install.sh ``` ### Options Pass options after `bash -s --`, for example `curl -fsSL …/install.sh | bash -s -- --port 9443`. | Option | Default | Meaning | |---|---|---| | `--dir DIR` | `/opt/mailsafehouse` | Where to install | | `--port PORT` | `8443` | HTTPS port of the web UI | | `--hostname NAME` | the server's FQDN | Name people use to reach it | | `--ref REF` | `main` | Branch or release tag to install | | `--dry-run` | | Check the server and show the plan; change nothing | | `--yes` | | Accept the plan without asking (for automation) | (docker)= ### Docker Mail Safehouse needs **Docker Engine 24.0 or later** with the **Compose plugin 2.20 or later**. Podman is not supported. - **No Docker yet:** the installer offers Docker Engine from Docker's own apt repository (`docker-ce`, `docker-compose-plugin` and friends). - **Docker from Ubuntu** (`docker.io`, `docker-compose-v2`) or **Docker CE**: used as it is; a missing or old Compose plugin is offered from the same source. - **A commercial Docker** (Mirantis Container Runtime, Docker Enterprise, Docker Desktop): used as it is and **never changed**. If it is too old, the installer says so and stops; upgrade it through your vendor. Docker Desktop is meant for workstations; on a server, Docker Engine is recommended. - **Docker as a snap:** not supported; remove it and run the installer again to get Docker from apt. ## After installing 1. **Back up the encryption key** `/opt/mailsafehouse/deploy/secrets/master_key` somewhere off the server. Without it, the credentials Mail Safehouse stores cannot be decrypted. 2. Open the address the installer printed, for example `https://backup.example.com:8443`. Your browser warns about the certificate: see [the certificate](#certificate). 3. Enter the setup token and create the first administrator, then follow {doc}`first-steps`. Lost the setup token? Get a new one (it works until the first administrator exists): ```bash cd /opt/mailsafehouse/deploy sudo docker compose exec api s365b setup-token ``` (certificate)= ## The certificate The web UI uses HTTPS with a certificate from Caddy's own local certificate authority, which suits a server on your LAN. Browsers warn until they trust that authority. To trust it, copy its root certificate off the server: ```bash cd /opt/mailsafehouse/deploy sudo docker compose exec proxy cat /data/caddy/pki/authorities/local/root.crt > mailsafehouse-root.crt ``` and import `mailsafehouse-root.crt` as a trusted root on the computers that use the web UI (or through your device management). ## Keep it off the internet Mail Safehouse holds a copy of every mailbox it backs up, and credentials for your tenant. **Run it on your LAN or behind a VPN, never exposed to the internet**, and allow its port only from the networks that need it. The installer adds no firewall rules. Note that Docker's published ports bypass `ufw`; see [network access](../planning/deployment.md#network-access-your-responsibility) for how to restrict them. ## Install by hand On another distribution, or to control each step: ```bash sudo git clone https://github.com/crimpac/mailsafehouse.git /opt/mailsafehouse cd /opt/mailsafehouse/deploy sudo ./init.sh backup.example.com 8443 # creates .env and secrets/master_key sudo docker compose up -d --build sudo docker compose ps # postgres, api (healthy), worker, proxy ``` See {doc}`../planning/deployment` for the settings in `.env`.