How to Create Incremental Backups in Debian 12 Bookworm
Categories:
5 minute read
Creating reliable and consistent backups is a fundamental part of system administration. Whether you’re managing a server, desktop, or development environment, backups ensure that your data can be recovered in case of hardware failure, accidental deletion, or other mishaps. In this post, we’ll focus on how to create incremental backups in Debian 12 Bookworm, using tried and tested command-line tools that are powerful, efficient, and well-integrated with the Debian ecosystem.
📦 What Are Incremental Backups?
Before diving into implementation, it’s essential to understand what incremental backups are.
An incremental backup only copies files that have changed since the last backup (whether that’s full or incremental). This makes incremental backups significantly faster and more space-efficient compared to full backups, which duplicate all files every time.
There are three primary backup types:
- Full backup: A complete copy of all selected files.
- Incremental backup: Copies only files that have changed since the last backup.
- Differential backup: Copies files changed since the last full backup.
✅ Why Use Incremental Backups on Debian?
Debian 12 Bookworm provides a stable foundation for systems that require reliability and control. Incremental backups are ideal in such environments because:
- They minimize storage requirements.
- Speed up backup processes by only copying changed data.
- Enable frequent snapshots without consuming much bandwidth or CPU time.
- Allow quick restores using a combination of full and incremental backups.
🛠️ Tools to Create Incremental Backups in Debian
There are several tools available on Debian 12 to create incremental backups. Some of the most common include:
rsync
tar
borgbackup
rdiff-backup
duplicity
For this article, we’ll focus on rsync, borgbackup, and rdiff-backup — each with its strengths and suitable for different use cases.
🔁 Method 1: Incremental Backups Using rsync
🔍 What is rsync?
rsync
is a fast, versatile file copying tool. While it’s often used for synchronizing directories, it can also perform incremental backups using hard links and archive modes.
🧱 Setup
First, install rsync:
sudo apt update
sudo apt install rsync
📂 Directory Structure
Let’s assume you want to back up /home/user/data
to /mnt/backup
.
You can structure the backup directory like this:
/mnt/backup/
├── backup-2024-04-01/
├── backup-2024-04-02/
🧪 Performing the First Full Backup
rsync -a --delete /home/user/data/ /mnt/backup/backup-2024-04-01/
🔄 Creating Incremental Backups with Hard Links
The key to incremental backups with rsync
is using the --link-dest
option, which compares the current backup with a previous one and hard-links unchanged files to save space.
rsync -a --delete --link-dest=/mnt/backup/backup-2024-04-01/ \
/home/user/data/ /mnt/backup/backup-2024-04-02/
This approach saves storage space by reusing unchanged files.
🧹 Automating with Cron
You can set up a daily cron job to run this automatically:
crontab -e
Add this line:
0 2 * * * /usr/bin/rsync -a --delete --link-dest=/mnt/backup/backup-$(date -d "yesterday" +\%F)/ /home/user/data/ /mnt/backup/backup-$(date +\%F)/
🔐 Method 2: Incremental Backups Using BorgBackup
🔍 What is BorgBackup?
BorgBackup is a deduplicating backup program that supports compression and encryption. It’s perfect for those who want a more robust and modern backup solution.
🧱 Install Borg on Debian 12
sudo apt update
sudo apt install borgbackup
📁 Initialize a Backup Repository
Let’s create a new backup repository in /mnt/borg-backups
:
borg init --encryption=repokey /mnt/borg-backups
You’ll be prompted to enter a passphrase for encryption.
🗂️ Create the First Backup (Archive)
borg create --stats /mnt/borg-backups::first-backup /home/user/data
🔁 Subsequent Incremental Backups
Borg will automatically store only the changed data blocks between backups, so all subsequent backups are incremental:
borg create --stats /mnt/borg-backups::backup-$(date +%F) /home/user/data
📋 Listing Archives
borg list /mnt/borg-backups
♻️ Pruning Old Backups
Borg includes a handy prune
command to automatically delete old backups:
borg prune -v --keep-daily=7 --keep-weekly=4 --keep-monthly=6 /mnt/borg-backups
This keeps 7 daily, 4 weekly, and 6 monthly backups.
🔁 Method 3: Incremental Backups with rdiff-backup
🔍 What is rdiff-backup?
rdiff-backup
is a simple yet powerful tool that combines the best features of rsync
and version control. It stores reverse diffs so you can restore files to their state at any given time.
🧱 Install rdiff-backup
sudo apt update
sudo apt install rdiff-backup
🧪 Perform Initial Backup
rdiff-backup /home/user/data /mnt/rdiff-backups
🔄 Subsequent Incremental Backups
You can run the same command again — rdiff-backup
automatically creates reverse diffs:
rdiff-backup /home/user/data /mnt/rdiff-backups
🕓 List Backup Increments
rdiff-backup --list-increment-sizes /mnt/rdiff-backups
⏪ Restore to Previous State
To restore to a specific time (e.g., 3 days ago):
rdiff-backup -r 3D /mnt/rdiff-backups /home/user/data-restored
🧩 Choosing the Right Tool
Tool | Best For | Pros | Cons |
---|---|---|---|
rsync | Lightweight backups with hard links | Simple, fast, widely supported | No built-in compression or encryption |
borgbackup | Advanced users needing encryption & deduplication | Secure, efficient, scriptable | Slightly steeper learning curve |
rdiff-backup | Easy versioned backups | Keeps versions, easy to restore | Can be slower with large diff chains |
🔒 Securing Your Backup Strategy
A backup is only as good as its protection. Keep these in mind:
- Use encryption (especially with Borg) if storing backups on external or remote drives.
- Test restore procedures regularly.
- Automate backups with
cron
,systemd timers
, or Anacron. - Store backups offsite when possible (e.g., cloud, remote server).
- Check backup integrity regularly using tools like
borg check
.
📌 Summary
Creating incremental backups in Debian 12 Bookworm can be done effectively using tools like rsync
, borgbackup
, or rdiff-backup
. Whether you’re a beginner or a seasoned sysadmin, there’s a solution that fits your workflow.
To recap:
- Use rsync for simple, fast local backups with hard links.
- Use borgbackup if you want deduplication, encryption, and advanced pruning.
- Use rdiff-backup for a nice balance between simplicity and versioning.
No matter which method you choose, the most important part is consistency — back up frequently, test your restores, and stay protected.
🔄 Next Steps
- Set up a script to automate your backup of choice.
- Explore remote backups using SSH.
- Consider integrating your backup with cloud storage using
rclone
+ your favorite backup tool.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.