I spent some time over the last couple of days researching how to get Kopia up and running for my setup. I’m sharing here for feedback/advice and in hopes that it may help someone if they want a similar configuration.
I used Repository server via Docker - #2 by jkowalski as the starting spot for this configuration.
Configuration description
- Kopia running on my local Ubuntu-based NAS (called metal-mind), taking snapshots on a regular basis of all files on the NAS.
- Kopia running in a container so its interaction with the host is obvious and self-documented.
- Kopia UI exposed to my LAN so I can have a convenient way of checking up on it if I’m curious.
- Backup destination (repository) is BackBlaze’s B2.
Directory Setup
mkdir /home/ubuntu/kopia
cd /home/ubuntu/kopia
mkdir {cache,config,logs}
chown 65532:65532 {cache,config,logs} # kopia container runs in rootless mode
/home/ubuntu/kopia/docker-compose.yml
version: '3.7'
services:
kopia:
image: kopia/kopia:latest
hostname: metal-mind
restart: unless-stopped
ports:
- 51515:51515
environment:
KOPIA_PASSWORD: SuperSecretRepositoryPassword
TZ: America/Los_Angeles
volumes:
- /home/ubuntu/kopia/config:/app/config
- /home/ubuntu/kopia/cache:/app/cache
- /home/ubuntu/kopia/cache:/app/logs
- /media/backup:/app/backup:ro
entrypoint: ["/app/kopia", "server", "--insecure", "--address=0.0.0.0:51515", "--override-username=kopia@metal-mind", "--server-username=kopia@metal-mind", "--server-password=SuperSecretPasswordForTheWebUI"]
Now you can docker-compose up -d
and Kopia server will run. The WebUI should be accessible via http://metal-mind:51515
, and you can login with the username and password from the bottom of the above docker-compose.yml
. From here you can configure your repository and snapshots through the UI.
If you need to use Kopia on the CLI, then you need to get the ID of the running container so you can issue commands within it.
Get Kopia’s Container ID
ubuntu@container-host:~/kopia$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d2f3af390431 kopia/kopia:latest "/app/kopia server -…" 13 hours ago Up 13 hours 0.0.0.0:51515->51515/tcp kopia_kopia_1
7f9fced43cf0 nginx:latest "/docker-entrypoint.…" 13 hours ago Up 13 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp nginx
...
Issue Kopia Commands
Kopia appears to come bundled with basically nothing in its image, including a shell. That means we’ll have to use docker exec
for each individual command we want to issue to kopia instead of just launching an interactive shell inside the container. This stripped down container also means we don’t have access to ls
or any other standard tools to examine or debug the system from the container’s point of view.
docker exec -t d2f3af390431 /app/kopia --help
docker exec -t d2f3af390431 /app/kopia policy set --global --compression=zstd
Restoration
You can now install Kopia on any other computer and connect to the same repository (Backblaze’s B2 in my case) and see any snapshots created by the server. Make sure to set the filter dropdown in the upper left corner to “All Snapshots”. While this is a good way of restoring files, I’m planning on doing any administration via the server UI (http://metal-mind:51515
).
Nginx
Finally, I configured Nginx to reverse proxy to Kopia. Since there are lots of guides for getting Nginx up and running, I’ll just post my config:
upstream kopia_backend {
server metal-mind:51515;
keepalive 32;
}
server {
include ssl.conf;
server_name kopia.my-domain.com;
# Don't expose Kopia to anything other than my local network
allow 192.168.100.0/24;
deny all;
#Forward real IP and host
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location / {
proxy_pass http://kopia_backend;
}
}