Intro
When you have a home server with a lot of data and services, it’s really important to back up your disks correctly in case of disk failure or accidental mistakes. The 3-2-1 rule is a common guideline that suggests you should have:
- 3 copies of your data
- 2 different places
- 1 copy kept off-site
One way to create an offline backup is by using BorgBackup as a server. It lets you back up a folder remotely with encryption. Borg uses a differential system, which means it only updates the files that have changed between the old and new versions, to improve the speed and efficiency of the backup process.
In this guide, I’ll show you how to configure a Borg server using Docker, enabling you to securely back up any folders from your home server disks.
Prerequisite
Before we start, ensure you have the following prerequisites:
- A server or machine with Docker installed.
- Basic understanding of Docker concepts such as containers, images, and volumes.
- Docker Compose.
- A remote machine where the backup will be stored.
Configuration
Log in to your remote machine and begin configuring your Borg server.
Create a borg-server
folder and navigate into it:
Create a docker-compose.yml
file with the content below:
Note
Borg uses the SSH protocol in server mode, which is why port 22 is the default. In our setup, we’ll map it to 8022 to avoid conflicts with the host SSH server.
Create the authorized_keys
file and copy your public SSH key from your home server. You can display the key using the command:
Start your Borg server using the command:
Now test the connection using the command from your home server:
You should be able to connect without a password if you have installed the public key correctly.
Backup
Now the borg server of the remote machine is running, you can test it using borg client.
Firstly, install borg client on your home server:
Now run the command to create a new test
backup repository:
Enter a passphrase to encrypt the folder.
Now verify the backup folder using the command info
:
It should display something like:
You can now create your first backup of /etc
using the command:
Conclusion
With the Borg server configured using Docker, you can now easily back up all your sensitive folders to a remote machine. This setup provides encryption and differential backups to minimize duplication and optimize transfer speed and time.
Resources
- Photo by Behnam Norouzi on Unsplash
- BorgBackup website: https://www.borgbackup.org/
- Docker BorgBackup image github: https://github.com/AnotherStranger/docker-borg-backup/