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.
Beta
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.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:
curl -fsSL https://raw.githubusercontent.com/crimpac/mailsafehouse/main/install.sh | bash
The installer first checks the server and shows its plan; nothing is installed until you agree. It:
Checks the Ubuntu version, memory and disk space.
Checks Docker (see Docker below) and offers to install it if it is missing.
Checks that port 8443 is free. If something else uses it, it shows what, and asks for another port.
Asks for the server’s DNS name.
Notes any other containers already running on the server.
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.
Prefer to read it first? Download it, read it, then run it:
curl -fsSLO https://raw.githubusercontent.com/crimpac/mailsafehouse/main/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 |
|---|---|---|
|
|
Where to install |
|
|
HTTPS port of the web UI |
|
the server’s FQDN |
Name people use to reach it |
|
|
Branch or release tag to install |
|
Check the server and show the plan; change nothing |
|
|
Accept the plan without asking (for automation) |
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-pluginand 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¶
Back up the encryption key
/opt/mailsafehouse/deploy/secrets/master_keysomewhere off the server. Without it, the credentials Mail Safehouse stores cannot be decrypted.Open the address the installer printed, for example
https://backup.example.com:8443. Your browser warns about the certificate: see the certificate.Enter the setup token and create the first administrator, then follow First steps.
Lost the setup token? Get a new one (it works until the first administrator exists):
cd /opt/mailsafehouse/deploy
sudo docker compose exec api s365b setup-token
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:
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
for how to restrict them.
Install by hand¶
On another distribution, or to control each step:
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 Deployment for the settings in .env.