How to Deploy a Kopia Repository Server on a VPS
Updated Nov 2026
verified on Ubuntu 26.04 · Nov 2026Run a Kopia repository server with its web UI on a VPS behind Caddy HTTPS, add a client user, restore a snapshot, and mirror the repository so you can recover it.
- A VPS with 1 GB+ RAM and enough disk for the backups it will hold
- A fresh Ubuntu 26.04 server with root/sudo SSH access
- A domain or subdomain you can point at the server
What this sets up
Kopia is an Apache-2.0 backup tool with encrypted, deduplicated snapshots. Here the VPS runs Kopia's repository server: your other machines send backups to it over HTTPS, each with its own user, and you get the web UI. The repository is a directory on the VPS disk, so mirror it somewhere else (see Backups). Kopia can also write straight to S3-compatible storage, B2 or SFTP without any server, which may be all you need for one machine.
Memory depends on repository size and how many clients are active, so watch
sudo docker stats under your real workload. Disk is what fills first.
Prepare the server
Update the system, install the tools this guide uses, and open only SSH and the two web ports:
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y curl openssl ufw dnsutils jq
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw --force enable
If you're logged in as root, create a non-root sudo user and continue as that user:
adduser deploy
usermod -aG sudo deploy
A published container port goes around ufw on a Docker host, so only what
should be public gets published below.
Install Docker
The convenience script installs Docker Engine and the Compose plugin (the Docker and Compose on Ubuntu guide covers the details):
command -v docker >/dev/null || curl -fsSL https://get.docker.com | sudo sh
sudo docker compose version
Paid link — we earn a commission if you shop through it.
Create the repository
Three secrets: the repository password (encrypts everything; lose it and the backups are unreadable), the web UI password, and a control password for administrative refreshes.
mkdir -p ~/kopia/{config,cache,logs,certs,repository} && cd ~/kopia
if [ ! -f .env ]; then
( umask 077
{ echo "DOMAIN=kopia.example.com"
echo "KOPIA_PASSWORD=$(openssl rand -hex 24)"
echo "UI_PASSWORD=$(openssl rand -hex 16)"
echo "CONTROL_PASSWORD=$(openssl rand -hex 16)"; } > .env )
fi
cat > compose.yaml <<'EOF'
services:
kopia:
image: kopia/kopia:0.23.1
hostname: backup-server
restart: unless-stopped
environment:
USER: admin
KOPIA_PASSWORD: ${KOPIA_PASSWORD}
KOPIA_SERVER_USERNAME: admin
KOPIA_SERVER_PASSWORD: ${UI_PASSWORD}
KOPIA_SERVER_CONTROL_USERNAME: control
KOPIA_SERVER_CONTROL_PASSWORD: ${CONTROL_PASSWORD}
command:
- server
- start
- --address=0.0.0.0:51515
- --tls-cert-file=/app/certs/server.cert
- --tls-key-file=/app/certs/server.key
volumes:
- ./config:/app/config
- ./cache:/app/cache
- ./logs:/app/logs
- ./certs:/app/certs
- ./repository:/repository
caddy:
image: caddy:2
restart: unless-stopped
ports: ["80:80", "443:443"]
environment:
DOMAIN: ${DOMAIN}
volumes: ["./Caddyfile:/etc/caddy/Caddyfile:ro", "./certs/server.cert:/etc/caddy/kopia.cert:ro", "caddy_data:/data"]
volumes:
caddy_data:
EOF
sudo docker compose run --rm kopia repository create filesystem --path=/repository
Remote Kopia clients speak gRPC, which needs TLS all the way to the server,
so --insecure will not do. Create a self-signed certificate for the internal
hop; Caddy trusts exactly that certificate and presents a public one outside:
cd ~/kopia
[ -f certs/server.cert ] || sudo openssl req -x509 -newkey rsa:2048 -nodes -days 3650 \
-keyout certs/server.key -out certs/server.cert -subj /CN=kopia -addext "subjectAltName=DNS:kopia"
cat > Caddyfile <<'EOF'
{$DOMAIN} {
reverse_proxy https://kopia:51515 {
transport http {
tls_server_name kopia
tls_trust_pool file /etc/caddy/kopia.cert
}
}
}
EOF
sudo docker compose up -d
HTTPS + domain
Create an A record for your hostname pointing at the server's public IP and confirm it resolves, because Caddy needs that to get a certificate (see Automatic HTTPS with Caddy):
dig +short kopia.example.com
. ~/kopia/.env
curl -s -o /dev/null --retry 30 --retry-delay 5 --retry-all-errors -f -u "admin:$UI_PASSWORD" \
-w 'with password: %{http_code}\n' "https://$DOMAIN/"
curl -s -o /dev/null -w 'without password: %{http_code}\n' "https://$DOMAIN/"
Expect 200, then 401. The web UI is at https://kopia.example.com; sign in as
admin with UI_PASSWORD.
Add a client user
Never hand clients the repository password. Give each machine its own user, named
user@hostname in lowercase. By default each user sees only its own snapshots.
cd ~/kopia
( umask 077; [ -f client-password ] || openssl rand -hex 16 > client-password )
sudo docker compose exec -T kopia kopia server user add alice@laptop --user-password="$(cat client-password)"
sudo docker compose restart kopia
On the client machine, install Kopia and connect (it asks for that user's
password). Keep the :443 in the URL: without an explicit port the connection
fails with missing port after port-separator colon.
kopia repository connect server --url https://kopia.example.com:443 --override-username=alice --override-hostname=laptop
kopia snapshot create ~/Documents
To check the whole path from the server, this uses a throwaway client container that goes through the public HTTPS address, backs up a test folder, restores it and compares:
cd ~/kopia && . ./.env
rm -rf ~/kopia-test && mkdir -p ~/kopia-test/src ~/kopia-test/out
echo "restore me" > ~/kopia-test/src/note.txt
sudo docker run --rm --hostname laptop -e KOPIA_PASSWORD="$(cat client-password)" -v ~/kopia-test:/t \
--entrypoint sh kopia/kopia:0.23.1 -c "
for i in 1 2 3 4 5 6 7 8 9 10; do
kopia repository connect server --url https://$DOMAIN:443 --override-username=alice --override-hostname=laptop && break
sleep 3
done &&
kopia snapshot create /t/src &&
kopia snapshot restore \$(kopia snapshot list /t/src --json | grep -o '\"obj\":\"[^\"]*' | tail -1 | cut -d'\"' -f4) /t/out"
diff -r ~/kopia-test/src ~/kopia-test/out && echo "client restore matches"
Backups
The VPS now holds backups, so it needs a second copy. repository sync-to
mirrors the encrypted repository to another location. Point it at storage off
this server (sync-to s3, b2, sftp and others). The example writes to a
local directory only so it can be run and checked as is:
cd ~/kopia && mkdir -p mirror
sudo docker compose run --rm -v ./mirror:/mirror kopia repository sync-to filesystem --path=/mirror
( umask 077; tar czf ~/kopia-server-config.tar.gz compose.yaml Caddyfile .env )
sudo du -sh repository mirror
Schedule the sync with cron, and keep .env (above all KOPIA_PASSWORD) in a
password manager.
To recover, copy the mirror back into the repository directory. This drill sets the original aside, restores, and reads a snapshot back:
cd ~/kopia && . ./.env
sudo test -n "$(sudo ls mirror)" &&
sudo docker compose stop kopia &&
sudo mv repository repository.old && mkdir repository &&
sudo cp -a mirror/. repository/ &&
sudo docker compose start kopia &&
curl -s -o /dev/null -f --retry 20 --retry-delay 3 --retry-all-errors -u "admin:$UI_PASSWORD" -w '%{http_code}\n' "https://$DOMAIN/" &&
sudo docker compose exec -T kopia kopia snapshot list --all &&
sudo docker compose exec -T kopia kopia snapshot verify --verify-files-percent=100
Once you are satisfied, remove repository.old. On a new server, unpack the
config archive, recreate the certificate, copy the repository in, connect with
sudo docker compose run --rm kopia repository connect filesystem --path=/repository
and add the client users again if they are missing.
Upgrades
Change the image tag in compose.yaml, then pull and recreate. Kopia 0.23.1
fixed a rare race that could lead to data loss, so do not run 0.23.0. Check the
release notes and keep clients close
to the server's version:
cd ~/kopia
sudo docker compose pull
sudo docker compose up -d
sudo docker compose exec -T kopia kopia --version
Troubleshooting
A client cannot connect. The URL must be your https:// address with the
port, as in https://kopia.example.com:443. Read
sudo docker compose logs kopia caddy; a new user is picked up after a restart
or a few minutes.
502 from Caddy. Kopia is not running, or the certificate was regenerated without recreating both containers.
"repository not initialized". The create step did not run, or config was
removed; connect to the existing repository again.
Disk full. Set retention policies with kopia policy set so old snapshots
expire.
Verification + next steps
This guide's run checked a client backup and restore through HTTPS and a recovery from the mirror, with a one-file test set. The web UI beyond its login, an off-server sync target and a version change were not tested.
You're done when a client has backed up and restored through HTTPS, and the repository is mirrored off the server. See the Kopia entry for catalog details and Best VPS for self-hosting for server picks.
Next steps
Common questions
How long does it take to follow "How to Deploy a Kopia Repository Server on a VPS"?
We estimate about 35 minutes of hands-on time for "How to Deploy a Kopia Repository Server on a VPS"; this is an editorial estimate, not a measurement.
Was the "How to Deploy a Kopia Repository Server on a VPS" guide tested?
The "How to Deploy a Kopia Repository Server on a VPS" guide was verified end-to-end on Ubuntu 26.04 (Nov 2026).