Dec 14, 2024 3 min read

Duplicati: The Ultimate Guide to Self-Hosting

Duplicati: The Ultimate Guide to Self-Hosting
Table of Contents

Duplicati is an open-source, self-hosted backup solution designed to securely manage and store your data on your preferred destination, including cloud storage providers or local file systems. It offers advanced encryption, compression, and deduplication features, making it an excellent choice for users who value data control and customization. In this guide, youโ€™ll learn how to install, configure, manage, and leverage Duplicatiโ€™s unique features through practical, code-focused examples.

Installing Duplicati

๐Ÿ“ฆ Docker/Docker Compose Setup

The easiest way to deploy Duplicati is via Docker. Below is a docker-compose.yml configuration tailored for Duplicati.


version: '3.7'

services:

duplicati:

image: lscr.io/linuxserver/duplicati:latest

container_name: duplicati

environment:

- PUID=1000                   # Adjust this to your user ID

- PGID=1000                   # Adjust this to your group ID

- TZ=Etc/UTC                  # Set the correct timezone

volumes:

- /path/to/config:/config    # Path to store configuration files

- /path/to/backups:/backups  # Path where backups will be stored

ports:

- 8200:8200                  # Port for accessing the web interface

restart: unless-stopped

Deploy the container using the following commands:


nano docker-compose.yml

## Start the container

docker-compose up -d

## Confirm Duplicati is running

docker ps | grep duplicati

Access the web interface at http://<your-server-ip>:8200.

๐Ÿš€ Manual Installation

To install Duplicati manually on a Linux server, follow these steps:


## Update your system

sudo apt update && sudo apt upgrade -y

## Install required dependencies

sudo apt install -y wget apt-transport-https gnupg

## Add Duplicatiโ€™s repository and key

wget https://updates.duplicati.com/beta/duplicati.asc

sudo apt-key add duplicati.asc

echo "deb https://updates.duplicati.com/beta/ stable main" | sudo tee /etc/apt/sources.list.d/duplicati.list

## Install Duplicati

sudo apt update

sudo apt install -y duplicati

## Enable and start the Duplicati service

sudo systemctl enable duplicati

sudo systemctl start duplicati

## Check service status

sudo systemctl status duplicati

Access the Duplicati interface at http://<your-server-ip>:8200.

Configuring Nginx as a Reverse Proxy

๐ŸŒ Nginx Configuration

Set up Nginx to route traffic to Duplicati for better accessibility and security. Below is an example duplicati.conf:


server {

listen 80;

server_name backup.example.com;

location / {

proxy_pass http://127.0.0.1:8200;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

Save the configuration file in /etc/nginx/sites-available/duplicati.conf and create a symbolic link:


sudo ln -s /etc/nginx/sites-available/duplicati.conf /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl reload nginx

๐Ÿ”’ SSL/TLS Setup

Secure your Duplicati instance with Letโ€™s Encrypt using Certbot:


sudo apt install -y certbot python3-certbot-nginx

sudo certbot --nginx -d backup.example.com

Automate certificate renewal:


sudo crontab -e

## Add the following line

0 3 * * * /usr/bin/certbot renew --quiet

๐Ÿ› ๏ธ Testing and Reloading Nginx

Check and reload your Nginx configuration:


sudo nginx -t

sudo systemctl reload nginx

Access Duplicati via https://backup.example.com.

Logging and Debugging Duplicati

๐Ÿ—ƒ๏ธ Enabling Debug Logs

Enable detailed debug logs in Duplicati for troubleshooting:

  1. Access the web interface.

  2. Go to Settings โ†’ Advanced Options.

  3. Set --log-level=Profiling.

๐Ÿ“„ Viewing Logs

For Docker deployments, view logs using:


docker logs duplicati

For manual installations, logs are stored in:


~/.config/Duplicati/Duplicati-server.sqlite

๐Ÿ› ๏ธ Troubleshooting Common Issues

For common issues like permission errors, check the logs for /backups directory access:


sudo chmod -R 770 /path/to/backups

๐Ÿ“ค Exporting Logs

Send logs to ELK Stack using a utility like Filebeat:

  1. Install Filebeat: sudo apt install filebeat.

  2. Edit /etc/filebeat/filebeat.yml to include Duplicati logs.

  3. Start Filebeat: sudo systemctl start filebeat.

Backup and Restore

๐Ÿ—‚๏ธ File-Based Backups

Run a manual backup of a directory via the Duplicati CLI:


duplicati-cli backup "file://path/to/backup/location" "/path/to/data" --backup-name="My Backup" --dbpath="/path/to/db" --encryption-module=aes --compression-module=zip

๐Ÿ”„ Database Backups

Export Duplicatiโ€™s internal database:


duplicati-cli export-db /path/to/store.db

Restore from the database:


duplicati-cli restore "file://path/to/backup/location" --restore-path="/path/to/restore"

๐Ÿ“… Automated Backup Scripts

Set up a cron job for automated backups:


crontab -e

## Run backup daily at midnight

0 0 * * * duplicati-cli backup "file://path/to/backup/location" "/path/to/data"

Updating and Upgrading Duplicati

โฌ†๏ธ Updating Docker Images

Update your Duplicati Docker container:


docker-compose pull duplicati

docker-compose up -d

๐Ÿ› ๏ธ Manual Updates

For manual installations, update the package:


sudo apt update

sudo apt upgrade duplicati

๐Ÿ” Checking for Updates

Verify available updates in the Duplicati UI under Settings โ†’ About.

Leveraging Duplicatiโ€™s Unique Features

๐Ÿ”ง Enabling APIs

Activate Duplicatiโ€™s API for advanced automation:

  1. Go to Settings โ†’ Advanced Options.

  2. Enable --webservice-interface=any.

  3. Use the API via curl:


curl -X GET http://127.0.0.1:8200/api/v1/version

๐ŸŒŸ Advanced Configurations

Use Duplicatiโ€™s pre-backup scripting capabilities to run custom commands:


duplicati-cli backup "file://path/to/backup" "/path/to/data" --run-script-before="/path/to/script.sh"

Wrapping Up

Duplicati provides a robust, flexible solution for managing backups on your terms. From secure installation to advanced configurations and automation, this guide equips you with the tools to self-host and optimize Duplicati for your needs. Start implementing these steps today and take control of your data backup strategy!

Great! Youโ€™ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.