Post

Using a Dedicated HDD in Proxmox for Daily ZFS Backups with rsync

Using a Dedicated HDD in Proxmox for Daily ZFS Backups with rsync

When running a home server or small lab using Proxmox VE, ensuring proper backups is essential. While USB drives are a solid offline backup solution, adding an online, internal backup drive to your Proxmox host can create an extra layer of safety and convenience. This post walks through how to set up a dedicated HDD for automated daily backups of your ZFS mirror using rsync.


❓ Why Use a Dedicated Internal Backup Drive?

Backups are a multi-layered game. Offline USB backups are great—but they’re manual and not always up-to-date. Having an internal drive that automatically mirrors your data once per day gives you:

  • 🕒 Quick access to recent data
  • 🔄 Automation-friendly setup
  • 🔒 Isolation from the main ZFS pool

This approach doesn’t replace your offline backups. It complements them. The goal is resilience, not redundancy.


🛠️ Hardware Setup: Adding the Backup HDD

You’ll need an additional HDD connected to your Proxmox server. This drive should not be added to your ZFS mirror.


🧭 Step 1: Identify the New Disk

Use lsblk or fdisk to identify the disk:

1
lsblk

Look for a device name like /dev/sdb with no partitions listed under it.


📐 Step 2: Create a New Partition

Use fdisk to create a new partition:

1
fdisk /dev/sdb

Follow this interactive guide:

  • n to create a new partition
  • p for primary
  • 1 to make it partition 1
  • Press Enter to accept default first and last sectors (use whole disk)
  • w to write changes and exit

📝 You may need to reboot or use partprobe to reload partition tables:

1
partprobe /dev/sdb

💾 Step 3: Format the Partition

Format the new partition (/dev/sdb1) to ext4:

1
mkfs.ext4 /dev/sdb1

📎 Step 4: Mount the Partition Using UUID

  1. 🔍 Find the UUID:
    1
    
    blkid /dev/sdb1
    

    Example output:

    1
    
    /dev/sdb1: UUID="a1b2c3d4-e5f6-7890-abcd-1234567890ef" TYPE="ext4"
    
  2. 🗂️ Create a mount point:
    1
    
    mkdir -p /mnt/backup_hdd
    
  3. 📝 Add the mount entry to /etc/fstab:

    Open /etc/fstab in your editor:

    1
    
    nano /etc/fstab
    

    Add this line (replace the UUID with yours):

    UUID=a1b2c3d4-e5f6-7890-abcd-1234567890ef /mnt/backup_hdd ext4 defaults 0 2
    
  4. 🔄 Mount all filesystems:
    1
    
    mount -a
    

✅ Now your backup HDD is mounted persistently at /mnt/backup_hdd using its UUID—safe and reliable!


🔄 Setting up rsync for Daily ZFS Backups

We’ll use rsync to sync selected directories from your ZFS pool to the backup drive.


📝 Create a Backup Script

Create the script at /usr/local/bin/rsync_zfs_backup.sh:

1
2
3
4
5
6
7
8
9
#!/bin/bash
SOURCE="/rpool/data/"
DEST="/mnt/backup_hdd/zfs_backup/"
LOGFILE="/var/log/rsync_zfs_backup.log"

mkdir -p "$DEST"
echo "[$(date)] Starting rsync backup..." >> "$LOGFILE"
/usr/bin/rsync -aAXHv --delete "$SOURCE" "$DEST" >> "$LOGFILE" 2>&1
echo "[$(date)] Backup complete." >> "$LOGFILE"

Make it executable:

1
chmod +x /usr/local/bin/rsync_zfs_backup.sh

⏰ Automating with cron

Edit root’s crontab:

1
crontab -e

Add this line to run the backup at 3:30 AM daily:

1
30 3 * * * /usr/local/bin/rsync_zfs_backup.sh

✅ That’s it! Your Proxmox system will now back up your ZFS data to the internal HDD daily.


🧪 Testing the Setup

To test:

  1. Run the script manually:
    1
    
    /usr/local/bin/rsync_zfs_backup.sh
    
  2. Check logs:
    1
    
    tail -f /var/log/rsync_zfs_backup.log
    

Make sure the destination is populated correctly, and re-run to confirm incremental behavior.


🛡️ Offline USB Backup: Still Important!

Even though this post is about internal HDD backups, don’t drop your offline USB routine. Offline backups protect against:

  • ⚡ Electrical faults
  • 🧬 Software bugs
  • 🦠 Ransomware

I typically rotate USB drives weekly and store them disconnected from the server. This internal disk is just an extra shield, not your final line of defense.


🧠 Final Thoughts

Backing up your ZFS mirror daily using an internal HDD and rsync is a practical, low-maintenance addition to any Proxmox server. It adds a nearline layer of protection without the complexity of snapshot replication or additional ZFS pools.

By combining:

  • ✅ Daily rsync to an internal drive
  • ✅ Weekly offline USB backups
  • ✅ A clear recovery plan

…you can sleep a little easier knowing your data is safer.

This post is licensed under CC BY 4.0 by the author.