Linux Backup with Borgmatic: Complete Guide to Protect Your Data
Protecting data is a priority for every Linux user, both personal and corporate. In this clear and comprehensive guide I will show you how to make a reliable and secure Linux backup using Borgmatic.
Whether you are looking for an incremental backup, a system to automate backups, or just a lightweight yet powerful solution, Borgmatic is an excellent choice.
👉 Want professional configuration and personalized support? Contact our Linux Support now!
Table of Contents
What is Borgmatic
Borgmatic is an open-source tool that automates the use of Borg Backup, a software for secure, compressed and deduplicated backups. It deals with:
- Creating backups
- Restoring data
- Checking the integrity of backups
- Rotating and managing backups
Why Choose Borgmatic for Backup on Linux
- Security: backups can be securely encrypted.
- Efficiency: thanks to deduplication, backups take up less space.
- Automation: schedule daily, weekly or monthly backups effortlessly.
- Flexibility: you can save backups to local or cloud devices.
- Reliability: supports automatic data integrity checking.
How to Install Borgmatic on Linux
1. Install Borg
sudo apt update
sudo apt install borgbackup
2. Install Borgmatic
sudo apt install borgmatic
Or:
pip install --user borgmatic
Configuring Borgmatic: Step-by-Step Guide
1. Create the configuration directory
sudo mkdir -p /etc/borgmatic
2. Generate a sample configuration file
sudo borgmatic config generate
For versions prior to 1.7.15 use this command instead to generate the configuration:
sudo generate-borgmatic-config
3. Edit the configuration file
sudo nano /etc/borgmatic/config.yaml
Main configurations:
source_directories
: the directories to be backed uprepositories
: paths to the backupretention
: rules for maintaining and cleaning backupsencryption_passphrase
: encryption password
Example:
location:
source_directories:
- /home
repositories:
- /mnt/backup-repo
retention:
keep_daily: 7
keep_weekly: 4
keep_monthly: 6
Performing Backup with Borgmatic
To manually start a backup:
sudo borgmatic
To schedule with Cron:
sudo crontab -e
For example, add:
0 2 * * * /usr/local/bin/borgmatic
To restore a Backup with Borgmatic
1. Backup list
sudo borgmatic list
2. Restore files
sudo borgmatic extract --path /home/user/documents
Best Practices for Linux Backups with Borgmatic
- Test your backups regularly.
- Keep backups on different devices.
- Use encryption.
- Document your configuration.
- Monitor the status of your backups.
Backup Strategies and Disaster Recovery Plan
Backup Strategies: the Basis of Data Protection.
An effective backup strategy is not just about randomly saving data. It is critical to plan regular backups, define what data is critical, choose the most suitable destination (local, remote or cloud) and protect backups with encryption systems. With Borgmatic, you can fully automate this process, scheduling daily or weekly backups and setting retention policies to manage space intelligently.
One of the most reliable practices is the 3-2-1 backup strategy: keep at least three copies of data, on two different media, with at least one off-site copy. This approach greatly reduces the risk of total loss, ensuring resilience even in the event of hardware failure or local disasters. Borgmatic can be configured to send backups to both local devices and remote or cloud storage, making it easy to adopt the 3-2-1 strategy.
Create a Comprehensive Disaster Recovery Plan (DRP).
Beyond simple backup, every business-even individual ones-should have a Disaster Recovery Plan (DRP). A good DRP defines what to do in the event of data loss, hardware failure, cyber attack, or natural disaster. Borgmatic integrates seamlessly into a DRP because of its ability to make fast, secure and easily recoverable backups. Having an up-to-date copy of Borgmatic's own configuration is an integral part of an effective recovery plan.
Testing Backup and Disaster Recovery Plan: The Key to Security.
Creating regular backups and having a Disaster Recovery Plan are critical steps, but without practical testing they remain only good intentions. Periodically testing the integrity of backups and simulating full or partial data recovery scenarios is essential. With Borgmatic, you can automate integrity tests via verification commands(borgmatic --verify
) and schedule test restores on separate environments. Running regular simulations ensures that backups are actually usable, that staff know how to proceed, and that any problems are detected before a real emergency occurs.
FAQ: Frequently Asked Questions.
Is it difficult to configure Borgmatic for a Linux novice?
No, the configuration is clear and documented. Following basic examples makes it easy to get a backup working.
Can I save backups to a cloud server?
Yes, Borgmatic supports remote backups via SSH or to compatible clouds.
Are backups with Borgmatic encrypted?
Yes, you can protect your backups with a secure password.
How much space do backups take up?
Thanks to deduplication, only what is new or changed is saved, saving space.
Conclusion
Borgmatic is a powerful, simple and efficient solution for managing Linux backup in a secure and automated way.