Docker volumes are a great way to persist container data in your server. Taking a backup of those docker volumes with duplicati is even easier.
In this blog, you will learn how to install and set up Duplicati to make periodic backups of your docker volumes.
Prerequisites to follow this guide
You should have a basic understanding of docker and how to use it in your system.
Installing Duplicati Docker Container
In this guide you will use linuxserver/duplicati docker container.
First, run the
id $user command in your terminal to get the user identifier
uid and group identifier
gid of the current user of the host machine.
root@debian:~# id $user uid=0(root) gid=0(root) groups=0(root)
If you are logged in as a root user, then the
gid for you will be
To run the linuxserver/duplicati container, execute the following command.
docker run -d \ --name=duplicati \ -e PUID=0 \ -e PGID=0 \ -e TZ=Etc/UTC \ -p 8200:8200 \ -v duplicati-config:/config \ -v /tmp/backups:/backups \ -v /:/source \ --restart unless-stopped \ lscr.io/linuxserver/duplicati:latest
Now open your browser and visit
http://<your server ip address>:8200 to access the Duplicati web UI.
Setting up Duplicati
After the first run is successful, stop the docker container using the
docker stop <container id> command. Let’s setting up Duplicati for backup docker volumes.
If you are using a graphical interface like portainer to manage docker container, then modifying container configuration will be very easy.
Otherwise, modify your previous docker command and map your docker volumes into the
/source directory of the Duplicati container.
docker run -d \ --name=duplicati \ -e PUID=0 \ -e PGID=0 \ -e TZ=Etc/UTC \ -p 8200:8200 \ -v duplicati-config:/config \ -v /tmp/backups:/backups \ -v volume1:/source/volume1 \ -v volume2:/source/volume2 \ --restart unless-stopped \ lscr.io/linuxserver/duplicati:latest
In the above command,
volume1 is mapped to the
/source/volume1 directory and
/source/volume2 directory, etc.
After mapping all the volumes you want to back up, restart your Duplicati container.
Running your first backup
Now click on the Add backup button and follow the instructions on the screen. Then expand the source directory and click on the docker volumes you want to get a backup.
When the setup is successful, click on the Run now link to run your first backup. Your backup will save to the
/tmp/backups directory. You can change this location to your home directory as well.
The above method creates a backup in your local machine. But duplicity offers you to save your backup folder in remote locations like s3 buckets.
To back up your data to s3 cloud buckets, select S3 compatible option from the Backup Destination popup. This is a great guide on how to backup your data to Amazon S3 from Linuxserver team.