Backing up PVE host ZFS boot disks to PBS

Aug 30, 2023
99
21
8
Luxembourg
I was hoping to find a glimmer of hope that PBS would support some kind of built-in way to back up the boot disks of my PVE hosts. I have a test host that uses just a single disk for booting, and I'd really like to find a way to back it up fully in case the disk dies. My main host has mirrored boot disks that at least grants me some protection, but even that I'd like to back up.

Some research brought up using snapshots as the boot disks use ZFS and then send them to backup storage, but I'm not sure how to integrate this into my PBS server. So far I have this:

### Backup Process

1. Create a Snapshot:
- First, create a snapshot of the rpool to capture the current state of the system.
zfs snapshot rpool/ROOT@backup

2. Send the Snapshot to a Backup Location:
- Use the "zfs send" command to send the snapshot to a backup location, such as an external drive or another ZFS pool.
zfs send rpool/ROOT@backup > /path/to/backup/backup.img

I also wondered if after the backup I should also remove the snapshot so I have this:

### Remove the Snapshot

1. List the Snapshots:
- First, list the snapshots to ensure you are removing the correct one.
zfs list -t snapshot

2. Remove the Snapshot:
- Use the "zfs destroy" command to remove the snapshot.
zfs destroy rpool/ROOT@backup

It looks quite straightforward, but I don't know if this would work or if there's anyway to automate it and use PBS for storage of the backups.

I did consider using Veeam to do this but I'd rather keep the number of backup solutions down to a minimum.

Also, yes I know rebuilding is fairly easy but it wouldn't recover the multitude of customisations I've done over time.
 
Understanding that you wanted to get that integrated into PBS, ideally.

Have you gotten far enough to test a restore based on that method? If so, can you provide any results?
 
It’s on Proxmox’s roadmap, no ETA.

I found a script on Reddit to back up the host to PBS. Not sure about a restore TBH but it feels better to have the backup. I’ll look tomorrow if I don’t get to it today.
 
It’s on Proxmox’s roadmap, no ETA.

I found a script on Reddit to back up the host to PBS. Not sure about a restore TBH but it feels better to have the backup. I’ll look tomorrow if I don’t get to it today.
No rush of course, I was just curious. If you want to pass a link to that script, I will check it out and see if I can test it on my side.
 
Understanding that you wanted to get that integrated into PBS, ideally.

Have you gotten far enough to test a restore based on that method? If so, can you provide any results?
Sorry, no, I decided to use Veeam for the moment doing just file level backups (as it can't do bare-metal of ZFS) - I'm trying to reduce the number of backup products I have in my home-lab, and this allowed me to remove one that was used purely for my hosts. Of course, I'd rather have a proper full backup.
 
  • Like
Reactions: wopner
From https://www.reddit.com/r/Proxmox/comments/vawwxd/can_proxmox_backup_server_backup_the_actual_pve/ :

With a couple modifications as discussed in that thread, and fixing of the Reddit-induced quote error:

Code:
#!/bin/bash
PbsStorage=$(grep pbs: /etc/pve/storage.cfg|awk '{print $2}')
export PBS_PASSWORD=`cat /etc/pve/priv/storage/$PbsStorage.pw`
export PBS_USER_STRING='root@pam!name'
#export PBS_SERVER='10.1.2.3'
export PBS_SERVER='pbs.example.com'
export PBS_DATASTORE='datastorename'
export PBS_REPOSITORY="${PBS_USER_STRING}@${PBS_SERVER}:${PBS_DATASTORE}"
export PBS_HOSTNAME="$(hostname -s)"
# fingerprint not needed for public cert
#export PBS_FINGERPRINT='1a:35:c4:a4:af:43:65:13:5a:6d:18:b6:6c:12:5b:19:90:d1:0c:79:83:33:15:ff:51:65:51:51:13:28:ff:94'
#backup PVE etc folder (this is due to it does not backup the PVE Dir)
#tar cf /root/pvebackup-\date +"%m%d%y"`.tar /etc/pve`
### PBS BACKUP HOST ##### (--ns is for PBS NameSpaces)
echo "Run pbs backup for $PBS_HOSTNAME ..."
proxmox-backup-client backup ${PBS_HOSTNAME}.pxar:/ --include-dev /etc/pve --skip-lost-and-found --ns 'name/space'
proxmox-backup-client list --ns 'name/space'
#Clean up PVE Dir tar file
#rm /root/pvebackup-\date +"%m%d%y"`.tar`
echo "Done."

One can save this as, say, /etc/pve/file.sh and run from crontab as "bash /etc/pve/file.sh".

HTH
 
  • Like
Reactions: wopner
From https://www.reddit.com/r/Proxmox/comments/vawwxd/can_proxmox_backup_server_backup_the_actual_pve/ :

With a couple modifications as discussed in that thread, and fixing of the Reddit-induced quote error:

Code:
#!/bin/bash
PbsStorage=$(grep pbs: /etc/pve/storage.cfg|awk '{print $2}')
export PBS_PASSWORD=`cat /etc/pve/priv/storage/$PbsStorage.pw`
export PBS_USER_STRING='root@pam!name'
#export PBS_SERVER='10.1.2.3'
export PBS_SERVER='pbs.example.com'
export PBS_DATASTORE='datastorename'
export PBS_REPOSITORY="${PBS_USER_STRING}@${PBS_SERVER}:${PBS_DATASTORE}"
export PBS_HOSTNAME="$(hostname -s)"
# fingerprint not needed for public cert
#export PBS_FINGERPRINT='1a:35:c4:a4:af:43:65:13:5a:6d:18:b6:6c:12:5b:19:90:d1:0c:79:83:33:15:ff:51:65:51:51:13:28:ff:94'
#backup PVE etc folder (this is due to it does not backup the PVE Dir)
#tar cf /root/pvebackup-\date +"%m%d%y"`.tar /etc/pve`
### PBS BACKUP HOST ##### (--ns is for PBS NameSpaces)
echo "Run pbs backup for $PBS_HOSTNAME ..."
proxmox-backup-client backup ${PBS_HOSTNAME}.pxar:/ --include-dev /etc/pve --skip-lost-and-found --ns 'name/space'
proxmox-backup-client list --ns 'name/space'
#Clean up PVE Dir tar file
#rm /root/pvebackup-\date +"%m%d%y"`.tar`
echo "Done."

One can save this as, say, /etc/pve/file.sh and run from crontab as "bash /etc/pve/file.sh".

HTH
Nice, thank you, I'll give that method a test. Just need to build up a sacrificial DR test host.
 
  • Like
Reactions: SteveITS