Docker Stack For Kopia
Tag is the version of Kopia
- latest
- 0.8.4
Use Docker Swarm to deploy. There are examples for using Traefik for SSL termination.
This is designed to be used as a Repository Server with clients that connect to it, but you can use the container on its own. The clients can be remote or they could be other docker stacks, the container uses like 15MB of RAM at rest so running a bunch is easy.
The Repository Server web interface can be exposed to the internet or accessed over your local network and can be used for managing the connected clients, or you can attach to the Repository Server container and run commands. The clients can have their web interface exposed but I wouldn't really recommend it.
Much of the process of creating repositories, users, and basic policies has been automated to try and make it easier to get setup, especially if you're going to connect a lot of clients.
Configuration consists of environment variables in the .yml
files.
The Kopia server communicates with traefik and the clients over HTTPS in order to proxy gRPC, as such you'll need to create a backend certificate for it.
- kopia.cert = The SSL certificate for the backend
- kopia.key = The SSL key for the backend
openssl req -x509 -nodes -days 14600 -newkey rsa:2048 -keyout ./kopia.key -out ./kopia.cert
Get the SHA256 value since that's how the clients check the servers certificate.
openssl x509 -in ./kopia.cert -noout -fingerprint -sha256 | sed 's/://g' | cut -f 2 -d =
I personally use this with Traefik as a reverse proxy, I've included an example traefik.yml
.
You'll need to create the appropriate Docker Secrets.
Run with docker stack deploy --compose-file docker-swarm.yml kopia
Any that begin with DE_
can use Docker secrets. Look at the documentation for more info on some of the environment variables https://kopia.io/docs/
DE_KOPIA_HOSTNAME
- Set the hostname used to connect to the Repository ServerDE_KOPIA_USERNAME
- Set the username used to connect to the Repository ServerKOPIA_SERVER_USERNAME
- Set the HTTP auth username for the serverDE_KOPIA_SERVER_PASSWORD
- Set the HTTP auth passwordTIME_ZONE
DE_KOPIA_USERS
- Add or update users to the Repository Server- A comma seperated list of users with the format
DE_KOPIA_USERNAME@DE_KOPIA_HOSTNAME,user2@hostname
- A 32 character password is randomly generated for each user and saved to
/app/config/userlist.txt
, connect to the container and back this up and then delete the file - Set the environment variable
DE_KOPIA_UPDATE_USERS
to true to update users with new passwords instead of adding them - Remove the environment variable after each use
- A comma seperated list of users with the format
DE_KOPIA_BLOCK_HASH
- Set the repository block hash, if not set on first run it'll run a benchmark and set it to the best resultDE_KOPIA_COMPRESSION
- Set the default compression type for the global policy, if not set on first run it'll run a benchmark and set it to the best resultDE_KOPIA_FIRST_BOOT
- Set to true on first boot to setup the repositoryDE_KOPIA_MAX_DOWNLOAD_SPEED
DE_KOPIA_MAX_UPLOAD_SPEED
DE_KOPIA_MAX_FILE_SIZE
DE_KOPIA_NEVER_COMPRESS
- a comma seperated list of file extensions that won't be compressed. The default is7z,rar,zip,bz,bz2,gz,lzma,lzo,tbz2,tgz,txz,xz,zipx
DE_KOPIA_REPOSITORY_PASSWORD
DE_AWS_SECRET_ACCESS_KEY
AWS_ACCESS_KEY_ID
DE_AWS_SESSION_TOKEN
DE_S3_BUCKET
DE_S3_ENDPOINT
DE_S3_REGION
- don't use for S3 compatible
AZURE_STORAGE_ACCOUNT
DE_AZURE_CONTAINER
DE_AZURE_SAS_TOKEN
DE_AZURE_STORAGE_DOMAIN
DE_AZURE_STORAGE_KEY
DE_B2_BUCKET
B2_KEY_ID
DE_B2_KEY
KOPIA_WEBDAV_USERNAME
DE_WEBDAV_FLAT
DE_WEBDAV_PASSWORD
DE_WEBDAV_URL
DE_KOPIA_ACTION_MODE
- https://kopia.io/docs/advanced/actions/DE_KOPIA_CLIENT
- set to true for client modeDE_KOPIA_CLIENT_PASSWORD
- password used to authenticate client with Repository ServerDE_KOPIA_SERVER_FINGERPRINT
- SHA256 hash of the Repository Server certificateDE_KOPIA_SERVER_URL
- change the server url to connect toDE_KOPIA_SNAPSHOT_TIME
- Set daily backup schedule timeHH:mm
format, this currently is GMT and is not affected byTIME_ZONE
HEALTHCHECKS_START_URL
- pings an endpoint with curl before backing up- I made a healthchecks.io docker stack as well
HEALTHCHECKS_SUCCESS_URL
- pings an endpoint with curl on successful back up- If using
HEALTHCHECKS_SUCCESS_URL
you can also setDE_KOPIA_SNAPSHOT_VERIFY
to a number between1-100
to verify that percentage of the snapshot
- If using
KOPIA_DIFF
- Displays differences between two repository objects (files or directories)KOPIA_RESTORE_CONSISTENT_ATTRIBUTES
- When multiple snapshots match, fail if they have inconsistent attributesKOPIA_SNAPSHOT_FAIL_FAST
- Fail fast when creating snapshotKOPIA_TRACE_FS
- Enables tracing of local filesystem operationsKOPIA_LOG_DIR_MAX_FILES
- Maximum number of log files to retainKOPIA_LOG_DIR_MAX_AGE
- Maximum age of log files to retainKOPIA_CONTENT_LOG_DIR_MAX_FILES
- Maximum number of content log files to retainKOPIA_CONTENT_LOG_DIR_MAX_AGE
- Maximum age of content log files to retainDE_KOPIA_AUTH_COOKIE_SIGNING_KEY
DE_KOPIA_CACHE_SIZE
- Default is 5000MBKOPIA_CACHE_DIRECTORY
KOPIA_CHECK_FOR_UPDATES
KOPIA_CONFIG_PATH
KOPIA_LOG_DIR
KOPIA_PERSIST_CREDENTIALS_ON_CONNECT