Post

Backing Up Proxmox ZFS Data to Offline USB Storage Using rsync

Backing Up Proxmox ZFS Data to Offline USB Storage Using rsync

Proxmox Virtual Environment (VE) is an open-source server virtualization platform that allows you to manage virtual machines and containers. One of the key features of Proxmox is its support for ZFS, a powerful file system and logical volume manager. ZFS enables high performance, data integrity, and efficient storage management. However, like all systems, your data is vulnerable to potential failures, and maintaining regular backups is crucial.

In this article, we will walk you through the process of backing up Proxmox ZFS data to an offline USB drive using the rsync-time-backup script. The script will allow you to create incremental backups of your Proxmox ZFS datasets to a USB drive. We’ll be using the backup system for offline storage to ensure that data is stored securely, even in the case of a system failure.


Step 1: Mount the USB Drive

To begin, you need to ensure that the USB drive is properly configured and mounted. In this case, the USB drive is configured in /etc/fstab using the following entry:

1
UUID=<UID> /media/usb ext4 defaults,noauto,noatime,nofail,errors=remount-ro 0 0

This entry tells the system to mount the USB drive at /media/usb when needed. The flags used in this configuration are explained below:

  • defaults: Use default mount options.
  • noauto: The drive will not be automatically mounted during boot.
  • noatime: Avoid updating the access time on files.
  • nofail: The system will continue booting even if the USB device is not available.
  • errors=remount-ro: If there is a file system error, remount the device as read-only.

Step 2: Install Dependencies

Before proceeding with the backup, you need to install the necessary dependencies. These include rsync and rsync-time-backup.

Run the following command to install rsync if it isn’t already installed on your system:

1
2
sudo apt update
sudo apt install rsync

Next, install rsync-time-backup by cloning the GitHub repository:

1
2
3
cd /opt
sudo git clone https://github.com/laurent22/rsync-time-backup.git
cd rsync-time-backup

Step 3: Configure rsync-time-backup Script

Now that you have the rsync-time-backup script, you need to configure it for your Proxmox system and the USB drive. The script will create backups of your ZFS datasets incrementally, storing each backup in a folder with a timestamp for easy reference.

  1. Create a Backup Directory
    First, create a backup directory on the USB drive to store your Proxmox backups:
1
sudo mkdir -p /media/usb/proxmox-backups
  1. Edit rsync-time-backup Script
    Next, you need to configure the script to back up your Proxmox ZFS datasets. Open the rsync-time-backup script for editing:
1
nano /opt/rsync-time-backup/rsync-time-backup.sh

In the script, modify the source and destination directories. For example, if your ZFS pool is named tank, change the following:

1
2
SRC="/tank"
DST="/media/usb/proxmox-backups"

You can also adjust other settings such as exclusion rules, backup schedule, and retention policies in the script.

  1. Set Permissions
    Make sure the script has the appropriate permissions to access the backup destination and the ZFS datasets. Run the following commands:
1
2
sudo chown -R root:root /media/usb/proxmox-backups
sudo chmod +x /opt/rsync-time-backup/rsync-time-backup.sh

Step 4: Running the Backup

With everything set up, you can now run the backup script. Since the USB drive is configured with the noauto option in /etc/fstab, you’ll need to manually mount it before the backup:

  1. Mount the USB Drive
    Run the following command to mount the USB drive:
1
sudo mount /media/usb
  1. Run the Backup Script
    Execute the rsync-time-backup script to start the backup:
1
sudo /opt/rsync-time-backup/rsync-time-backup.sh

This will begin the backup process, copying your ZFS datasets to the USB drive. The script will perform an incremental backup, ensuring that only new or modified files are backed up.

Do not forget to unmount and remove the USB drive after the backup!

1
sudo umount /media/usb

Since the backup is meant to be offline, you should put the USB drive after the backup into a safe location!


Final words

By using the rsync-time-backup script, you can easily back up your Proxmox ZFS data to an offline USB drive. This solution provides incremental backups, which are space-efficient and easy to restore. Additionally, the ability to disconnect the USB drive after the backup ensures that your data is safe even if your primary system fails.

Make sure to periodically check your backups to ensure that they are functioning as expected, and you’ll have peace of mind knowing that your Proxmox data is safe and secure.

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