Running BorgBackup & Restore on Docker
Daniel Nashed – 26 March 2021 04:39:49
Borg Backup https://borgbackup.readthedocs.io/en/stable/quickstart.html
is a great solution for optimized backup repositories either local or a remote location.
It supports encrypted repositories local or remote, compression and deduplication!
Now that I moved some of my servers into containers running on Podman, I looked into backup options inside the container.
For now I am preparing our Docker repository to include the Borg Backup option.
This includes adding Borg Backup to the image and also enabling the container to use the fuse user space mountable file-system.
Borg Backup on CentOS automatically installs the required fuse components. SUSE Lead had issues and the fuse integration ran into python errors, even installing the right package.
The Redhat UBI image doesn't provide the Borg packages at all. So my blog post and the new integration is focused on our main build platform CentOS.
Borg Backup in a container
Let's have a quick look what is required and how it works. Those additional steps will be included in our Docker image for Domino, so don't worry about details.
It's still interesting to see what needs to be done.
Borg Backup requires the "fuse" user space mount functionality for backup store.
The standard restore option isn't really flexible for the restore target. So mounting a backup is the best working option.
Run the container with fuse support
Fuse requires a device and an additional capability added to your container to use it.
So when running the container you have to add the following two options:
docker run --rm -it --device /dev/fuse --cap-add SYS_ADMIN centos:latest bash
In my test I manually installed borgbackup inside the container. But it will be part of the image we provide for Domino.
yum install -y epel-release
yum install -y borgbackup
The borg package automatically installs dependencies including the fuse tools.
So after installing this package your are all set to run your first backup.
Testing your Borg Backup setup
Because we want to run our backup and restore run with the notes user, let's add notes user and test the Borg Backup setup.
First add an user and create directories for the backup repository and a restore mount point:
adduser notes -U
mkdir -p /local/borg
mkdir -p /local/restore
chown notes:notes /local
su - notes
Create a borg repository
Creating a borg repository is a very straightforward operation. For the sake of this simple test, I am using an unencrypted repository first.
borg init -e=none /local/borg
This one command just creates your borg repository and you are ready for your first backup
Create a backup
This command creates a new backup "test" backing up your current host file.
borg create /local/borg::test /etc/hosts
This command writes the host file into the repository.
Restoring using a mount
Now let's mount our new backup to the mount created earlier.
borg mount /local/borg::test /local/restore
Now you can copy all relevant files back and finally you can unmount the restore
borg mount /local/restore
Conclusion and next step
After this basic groundwork I can take Borg Backup into the image.
All will be pre-installed when you build your image.
And the docker_container script will have a Borg option ;-)
Now what is just missing is a Domino integration for on-line backup and restore ...
- Comments [0]