Skip to content
ProHomeLab
RU

Backup

Duplicati - Encrypted Backups for Your Home Server

Stilicho2011Updated 8 min read24 views

Also available in: RU

Duplicati - Encrypted Backups for Your Home Server
Part 1 of 4 in the series Backup
  1. Duplicati - Encrypted Backups for Your Home Server
  2. Zerobyte - Backup Automation for Self-Hosted Infrastructure
  3. Proxmox Backup Server 4.2.0 - Installation, Configuration, and Proxmox VE Backup
  4. Vinchin Backup & Recovery V9.0 SP3 - Overview and Hands-On with Proxmox VE
Contents
Tip

If you enjoyed this article, you can become a sponsor on Boosty.

Duplicati + Docker - automatic backups in 10 minutes

Backups are one of the most important parts of any infrastructure.
Even in a homelab - and really, everywhere else too - losing data can be very costly. And it's not just about the data itself, but also the time it takes to restore it. It's quite possible the latter ends up being even more expensive.

Note

I have a video on my YouTube channel about installing and configuring Proxmox Backup Server. But that's a fairly specific solution, and not everyone runs Proxmox in their homelab. If you'd rather have a more flexible, restic-based setup, Zerobyte is worth a look too.

In this article, we'll cover:

  • what Duplicati is
  • how to install it on a server
  • how to set up automatic backups
  • how to store backups locally and in the cloud
  • how to restore your data and make sure the backup actually works

What is Duplicati

Duplicati is an open-source backup system that supports:

  • AES-256 encryption
  • deduplication
  • incremental backups
  • cloud storage
  • a web management interface

Supported storage:

  • S3
  • Backblaze B2
  • Google Drive
  • WebDAV
  • FTP / SFTP
  • local disks
  • NAS

This makes it a great solution for Homelab and self-hosted infrastructure, since it covers everything a typical homelabber needs.


Key features

Among the main features, it's probably worth highlighting:

Encryption

All data can be encrypted client-side before being sent.

Supported:

  • AES-256
  • passphrase protection

This means even the cloud provider can't read your data. In other words, you can be relatively at ease about backups in the cloud and about nobody training their AI models on your data.


Incremental backups

Duplicati stores data in blocks.

This lets it:

  • save only the changes
  • reduce storage size
  • speed up backups

Since the system only saves the information that actually changed, everything happens very quickly, and it's easier for us to plan disk space usage.


Web interface

After installation, you get a convenient web panel.

Through it you can:

  • create jobs
  • manage the schedule
  • restore files
  • check backup status

There's not much to explain here, honestly. Of course, seasoned admins might turn up their noses - "a graphical interface, how tacky." But don't fall for the provocation. A GUI is fine. As long as it wasn't drawn by a middle-schooler.


Installation - the docker-compose file from the video

I used the build (image) from linuxserver.io as the most user-friendly option for a homelab.

yaml
services: # Section describing all Docker services
duplicati: # Service name
image: lscr.io/linuxserver/duplicati:latest # Docker image, latest Duplicati version from LinuxServer
container_name: duplicati # Container name in Docker
hostname: duplicati # Hostname inside the container
entrypoint: # Override the container's entrypoint
- /init # Uses the /init script provided by the LinuxServer image
#ports: # Publish container ports on the host
# - 8200:8200 # MGMT UI - Duplicati's management interface will be available on port 8200
#expose: # Port that will be visible to other containers on the Docker network
# - 8200
environment: # Environment variables for the container
- PUID=0 # User UID inside the container (0 = root, typically for testing/administration)
- PGID=1000 # Group GID inside the container (should match your group on the host)
- TZ=Europe/Moscow # Container timezone
- SETTINGS_ENCRYPTION_KEY=<long_random_string> # Key that encrypts Duplicati's settings (required)
- DUPLICATI__WEBSERVICE_PASSWORD=<web_ui_password> # Web interface password (must be changed!)
restart: unless-stopped # The container will automatically restart if it crashes, except on manual stop
volumes: # Mounting host directories into the container
- /home/stilicho/docker/duplicati/backups:/backups # Directory for storing backups
- /home/stilicho/docker/duplicati/config:/config # Duplicati configuration and settings
- /home/stilicho/docker:/source # Directory with source files to back up (can be changed)
networks: # Docker network the container will run in
- proxy
labels: # Labels for Traefik (reverse proxy)
- "traefik.enable=true" # Enable Traefik handling for this container
- "traefik.docker.network=proxy" # Use the proxy network for Traefik
- "traefik.http.routers.duplicati.entrypoints=web" # Traefik entrypoint (port 80)
- "traefik.http.routers.duplicati.rule=Host(`duplicati.stilicho.ru`)" # Domain the service is available on
- "traefik.http.middlewares.duplicati-https-redirect.redirectscheme.scheme=https" # Redirect HTTP -> HTTPS
- "traefik.http.routers.duplicati.middlewares=duplicati-https-redirect" # Attach the redirect middleware
- "traefik.http.routers.duplicati-secure.entrypoints=websecure" # Traefik HTTPS route (port 443)
- "traefik.http.routers.duplicati-secure.rule=Host(`duplicati.stilicho.ru`)" # HTTPS domain
- "traefik.http.routers.duplicati-secure.tls=true" # Enable TLS
- "traefik.http.routers.duplicati-secure.tls.certresolver=cloudflare" # Use Cloudflare for certificate generation
- "traefik.http.routers.duplicati-secure.service=duplicati" # Assign the service for the route
- "traefik.http.services.duplicati.loadbalancer.server.port=8200" # Service port inside the container for Traefik
#- traefik.http.routers.duplicati.middlewares=ipwhitelist@file # (commented out) example of IP restriction
networks: # Section describing networks
proxy: # Network named proxy
external: true # Use an external Docker network created beforehand (e.g. for Traefik)
Important
  • PUID=0 means root inside the container. For production, it's better to use an unprivileged user.
  • SETTINGS_ENCRYPTION_KEY and DUPLICATI__WEBSERVICE_PASSWORD must be changed to your own values, otherwise the data and web interface are insecure. SETTINGS_ENCRYPTION_KEY encrypts Duplicati's settings database (which also holds your storage credentials and backup passphrases); the image requires at least 8 characters, letters and digits only. openssl rand -hex 32 gives you a suitable one.
  • The entrypoint: /init section is optional: /init is already the default entrypoint in linuxserver.io images.
  • Backing up database folders (PostgreSQL, MariaDB, etc.) while they're running can leave you with an inconsistent copy. For those services, it's safer to dump the database before the backup or stop the container - Duplicati has the --run-script-before and --run-script-after options for exactly that.
  • /source mounts the entire /home/stilicho/docker; if you don't need to back up everything, it's better to narrow the path down to specific folders.
  • The Traefik labels handle HTTPS and redirects. If Traefik isn't set up yet, they can be removed until the proxy is configured.
  • Passwords and other sensitive values are best kept in a separate .env file.

Working with the app

Since I already have a video review, in this article I'll only cover the key details.

After installing the app, go to the subdomain. A welcome screen will open, where you need to enter the admin password specified in the docker-compose file.

Duplicati web UI login screen - entering the admin password

We're met with a fairly minimalist menu with a "retina-burning" light mode. Dark mode can be enabled in the Settings section.

Duplicati home screen with a list of backups (empty for now)

In the Add backup section, you can choose the action you want: create a new backup or restore one from a config file (if you have one).

Add backup screen: choose to create a new backup or import from a file

Since we need to create a backup, we choose the Add new backup option.

In the menu that appears, we set the necessary parameters. If you want, you can enable encryption for the backup.

General backup settings: name, description, and AES-256 encryption

In the next two windows, we choose:

  • where to store the backup
  • which service to use

In the video I chose File system, since I was backing up demo files to storage mounted via fstab.

Choosing the destination storage type: File system, S3, SSH, and others

Choosing the file system path for storing the backup

The app will offer to test the connection.

Connection test dialog for the destination storage

If everything's fine, the next window lets you choose the files to back up.

In our case, we choose the source directory, since that's what's specified in the docker-compose file:

Choosing the source directory for backup

yaml
/home/stilicho/docker:/source # Directory with source files to back up (can be changed)

Next, we set the backup schedule.

Backup schedule configuration - daily run at 13

The next window lets you configure additional parameters: volume size, number of retained copies, and so on.

Additional backup parameters: volume size and retention policy

Once the setup is done, your backup jobs will appear in the Home section.

The created backup job in the My backups list

Restoring and testing backups

A backup you've never tried restoring from isn't a backup - it's a hope. So let's at least walk through the restore process briefly; the video shows the whole thing step by step.

Where to restore from

Restores start from the Restore section. You have three options:

  • From an existing job. If the job is in the list, just pick it. This is the fastest option: Duplicati gets the file information from its local database instead of pulling it from storage.
  • Restore from configuration - if you have an exported job configuration file (more on that below).
  • Direct restore from backup files - for when the server died and took Duplicati with it, and you're setting everything up from scratch. Enter the same storage you used when creating the backup, check it with Test connection, and type in the encryption passphrase. This one is slower: Duplicati has to download and process part of the data from storage to figure out which versions are there.
Warning

Without the encryption passphrase, an encrypted backup cannot be restored - period. Don't keep it on the same server you're backing up; put it somewhere like a password manager such as Vaultwarden. Otherwise you end up with the classic: the key to the safe is locked inside the safe.

Choosing the version, files, and options

Next, Duplicati shows the list of backup versions (the most recent one by default). Pick the version you need, select the files or folders, and move on to the restore options:

  • restore files to their original location or to a different folder;
  • if the target folder isn't empty, you can keep the existing files and save the restored copies next to them with a timestamp in the name;
  • file permissions are not restored by default: the users and groups from the original machine may not exist on the new one.

For Docker services, it's safer to restore not on top of the live files but into a separate folder, say /backups/restore (on the host that's /home/stilicho/docker/duplicati/backups/restore), and copy over what you need from there. And if you do restore to the original location, stop the container whose files you're bringing back first - otherwise the service may overwrite them mid-restore.

Exporting the job configuration

It's worth saving each job's configuration somewhere off the server. Expand the job in the list, click Export..., and choose To File. The file includes both the storage credentials and the backup passphrase, so when exporting either untick Export passwords (and keep the passwords elsewhere) or encrypt the file itself with a strong passphrase. To bring a job back from that file, go to Add backup → Import from file.

Testing your backups

After every backup, Duplicati downloads a few random files from storage and checks their integrity. By default that's one file of each type; you can change the amount with --backup-test-samples and --backup-test-percentage.

But that check only tells you the files in storage aren't corrupted - not that your data can actually be rebuilt from them. So every now and then, do a test restore: grab a couple of folders, restore them to a separate location, and make sure what's inside is what you expect. It takes a couple of minutes and will one day save you a whole lot of nerves.

For the truly bad day when Duplicati itself won't run, the project has separate disaster recovery tools - a Python script and the RecoveryTool console utility, which can pull files straight out of the backup files.