Hey everyone,
I recently rebuilt my homelab as 3 devices and I wanted to share my automation that powers the automated backup system.
Hardware
- A NUC with Proxmox Virtual Environment (PVE) that runs my HASS VM
- A NUC that runs Proxmox Backup Server (PBS)
- A NAS
The PBS node backs up and deduplicates the PVE containers every night, but I didn’t want to have to run it 24/7. I figured I could use the HTTP APIs of both PVE and PBS to automate the process. But how can I tie this all together into a recurring automation? The answer is Home Assistant of course ![]()
The automation
- 03:00 - HA sends a Wake-on-LAN magic packet to PBS
- HA waits for the Ping binary sensor to go on
- HA calls the PVE REST API to start a vzdump
- When the job finishes, PVE fires a webhook back to HA
- HA calls the PBS API to shut it down
I also documented the whole build and the automation process here: Automating Proxmox Backups with Home Assistant (and on YouTube: https://www.youtube.com/watch?v=GT0eXgGsZFI).
Config
This is the YAML configuration that made this possible:
configuration.yaml
wake_on_lan:
rest_command:
pve_start_backup:
url: "https://<PVE_IP>:8006/api2/json/nodes/pve/vzdump"
method: POST
headers:
Authorization: !secret pve_api_token
content_type: "application/x-www-form-urlencoded"
payload: "storage=pbs&mode=snapshot&compress=zstd&all=1"
verify_ssl: false
pbs_shutdown:
url: "https://<PBS_IP>:8007/api2/json/nodes/localhost/status"
method: POST
headers:
Authorization: !secret pbs_api_token
content_type: "application/x-www-form-urlencoded"
payload: "command=shutdown"
verify_ssl: false
automations.yaml
- id: pbs_backup_cycle
alias: PBS Backup Cycle
trigger:
- platform: time
at: "03:00:00"
action:
- service: wake_on_lan.send_magic_packet
data:
mac: "<PBS_MAC>"
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.pbs_online
to: "on"
timeout: "00:05:00"
continue_on_timeout: false
- delay: "00:00:30"
- service: rest_command.pve_start_backup
- wait_for_trigger:
- platform: webhook
webhook_id: pbs_backup_complete
local_only: true
timeout: "02:00:00"
continue_on_timeout: true
- service: rest_command.pbs_shutdown
And in PVE I configured a notification target pointing at http://<HA_IP>:8123/api/webhook/pbs_backup_complete (POST, body {}) and a matcher on exact:type=vzdump, with the backup job set to notification-system.
Conclusion
It was a bit of work, but I have my whole homelab running at about ~70W in 3U, and the PBS node is only awake for about 10 minutes a night. Really happy to have found the Ping and Wake on Lan integrations.
I wonder if anyone else has used these integrations before, and I’m happy to answer any questions!