Proxmox Backup Server automation is what separates a proper homelab backup strategy from just “it runs somewhere.” In Part 1, we installed PBS on dedicated N100 hardware, configured the datastore, and connected it to Proxmox VE. But the machine has been running 24/7 since then — and that’s a waste of power for something that only needs to be on for ~30 minutes a day.
In Part 2, we fix that. I’ll show you how to build a complete Proxmox Backup Server automation using Home Assistant and an ESP32-S3 Super Mini: the PBS machine powers on at 07:55 via a transistor circuit triggered by HA, runs the backup, then shuts itself down automatically when all tasks are done. And if the power is out and you’re running on UPS battery — PBS won’t start at all. 🏠
Why Home Assistant for Proxmox Backup Server Automation?
You could use a BIOS RTC alarm to wake the machine on a schedule. Simple, no dependencies. But it knows nothing about the outside world — it’ll happily start PBS at 07:55 even if your power has been out since 07:00 and you’re draining your UPS battery.
Home Assistant already knows:
- 🔌 Whether mains AC power is available
- ⏰ The current time
- 📡 How to trigger ESPHome devices over the network
Proxmox Backup Server automation through HA means one automation YAML that handles all of this logic cleanly. The Proxmox Backup Server automation approach I use relies on my HA server running on a dedicated mini PC with its own battery backup, so it’s always online even during outages — the perfect controller.
The PBS machine itself is powered via a DC barrel jack adapter — Wake-on-LAN requires standby power on the NIC which DC adapters typically don’t provide in S5 state. Instead, we use an ESP32-S3 Super Mini with a transistor to simulate a physical power button press. ESPHome makes this a native HA entity with zero custom code on the HA side. This is exactly what makes the Proxmox Backup Server automation approach clean — HA calls a button entity, ESPHome handles the hardware, no HTTP servers, no custom scripts.
Prerequisites ✅
Before building the Proxmox Backup Server automation, make sure you have:
- Part 1 completed — PBS installed, datastore configured, connected to Proxmox VE
- Home Assistant running with network access
- UPS integrated into Home Assistant with an entity that reflects AC input status
- ESP32-S3 Super Mini flashed with ESPHome
- NPN transistor (2N2222A works perfectly)
- 1kΩ resistor
- A backup job already configured in Proxmox VE pointing to PBS
Step 1 — Wire the Transistor Circuit 🔧
The idea is simple: ESP32-S3 GPIO outputs 3.3V → transistor opens → short-circuits the PWR_SW pins on the motherboard for 400ms → PBS boots. Exactly what the physical power button does.
We also add a power state sensor connected to the PWR_LED header so ESPHome knows whether PBS is already running — a critical safety feature for any Proxmox Backup Server automation that prevents accidental shutdown if the button is pressed while the server is on.
Components:
- 2N2222A NPN transistor
- 1kΩ resistor
- 4 wires to motherboard (PWR_SW × 1, PWR_LED− × 1, GND × 1, 5V × 1)
How to identify 2N2222A pins:
Hold the transistor with the flat side facing you, legs pointing down. Left to right:
[ Emitter | Base | Collector ]
E B C
PWR_SW wiring:
ESP32-S3 GPIO4 ──[1kΩ]──► Base (B)
Collector (C) ──► PWR_SW pin 1
Emitter (E) ──► GND (ESP32-S3)
ESP32-S3 GND ────────────────────────────► Motherboard GND (any internal USB)
ESP32-S3 5V ────────────────────────────► Motherboard 5V (any internal USB)
⚠️ ESP32-S3 GND must be connected to motherboard GND — without this the circuit won’t work.
⚠️ PWR_SW pulse must be short — 400ms simulates a button press. Holding the transistor open for 4+ seconds triggers a forced shutdown on a running machine.
PWR_LED wiring (power state sensor):
The PWR_LED header on the motherboard has two pins: LED+ (always 5V from standby) and LED− (switched to GND by the motherboard when the system is on). Connect LED−, not LED+:
ESP32-S3 GPIO5 ──► PWR_LED− (motherboard)
⚠️ Do not connect GPIO5 to LED+ — it carries 5V which exceeds the ESP32-S3’s 3.6V GPIO maximum. LED− safely swings between 0V (system on) and floating (system off).
Step 2 — Flash ESPHome on the ESP32-S3 Super Mini 📡
If you haven’t used ESPHome before, install it as a Home Assistant add-on: Settings → Add-ons → ESPHome. Connect your ESP32-S3 via USB and create a new device.
Full ESPHome configuration:
esphome:
name: pbs-power
esp32:
board: esp32-s3-devkitc-1
variant: ESP32S3
framework:
type: arduino
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "PBS Power Fallback"
password: !secret fallback_password
captive_portal:
api:
encryption:
key: !secret api_encryption_key
ota:
- platform: esphome
password: !secret ota_password
logger:
# GPIO4 - transistor base via 1kΩ resistor to PWR_SW
output:
- platform: gpio
pin: GPIO4
id: pwr_transistor
# GPIO5 - connected to PWR_LED- (not LED+!)
# LED- is LOW when system is on, floating when off
binary_sensor:
- platform: gpio
pin:
number: GPIO5
mode:
input: true
pullup: true
inverted: true
name: "PBS Power State"
id: pbs_power_state
device_class: power
filters:
- delayed_on: 500ms
- delayed_off: 3s
# Power button - only triggers if PBS is off
button:
- platform: template
name: "PBS Power Button"
on_press:
- if:
condition:
binary_sensor.is_off: pbs_power_state
then:
- logger.log: "PBS is off - pressing power button"
- output.turn_on: pwr_transistor
- delay: 400ms
- output.turn_off: pwr_transistor
else:
- logger.log: "PBS already running - skipping"
Flash it via ESPHome dashboard. After flashing, the device appears automatically in Settings → Devices & Services → ESPHome as a new device with two entities: button.pbs_power_button and binary_sensor.pbs_power_state. This is your Proxmox Backup Server automation trigger point.
Step 3 — Verify the Button Works 🧪
Before creating the automation, test manually in HA:
Developer Tools → Actions → search button.press
action: button.press
target:
entity_id: button.pbs_power_button
Click Perform action — PBS should boot within a few seconds. If it does, the hardware and ESPHome config are correct. ✅
Step 4 — Create the Home Assistant Proxmox Backup Server Automation 🤖
This is the core of the Proxmox Backup Server automation. Go to Settings → Automations → Create Automation → Edit in YAML and paste:
alias: "Start PBS backup server"
description: "Power on PBS at 07:55 so it's ready when backup job starts at 08:00"
trigger:
- platform: time
at: "07:55:00"
condition:
- condition: state
entity_id: binary_sensor.electricity_absence
state: "off"
action:
- action: button.press
target:
entity_id: button.pbs_power_button
mode: single
The condition logic: binary_sensor.electricity_absence = "off" means AC power is present — PBS will only start when mains electricity is available. If it’s "on", electricity is absent and PBS stays off, protecting your UPS battery. 🔋
Step 5 — Auto-Shutdown PBS After Backup Completes 🔌
The Proxmox Backup Server automation isn’t complete without the other half: PBS shutting itself down after the backup finishes. We don’t want it running until someone manually powers it off.
One important detail: when Proxmox VE backs up multiple containers, there are short gaps between them — one container finishes, the next hasn’t started yet. A naive “shutdown when task list is empty” script would power off PBS right in the middle of a multi-container backup job. ⚠️
The script below handles this correctly with two phases:
Phase 1 — Wait for backup to start (up to 30 minutes): the script sits and waits until at least one backup task appears in the task list. This prevents early shutdown before PVE even sends the first backup job.
Phase 2 — Idle monitoring: once a backup has been seen, the script tracks how long the task list has been empty. It only triggers shutdown after 5 consecutive minutes of no active tasks. A 10–30 second gap between containers won’t fool it — only genuine completion of the entire job will.
On your PBS machine, create the shutdown watcher script:
cat > /usr/local/sbin/pbs-auto-shutdown.sh << 'EOF'
#!/bin/bash
# Wait for all PBS backup tasks to complete, then shut down
MAX_WAIT=7200 # maximum wait time: 2 hours
INTERVAL=60 # check every 60 seconds
IDLE_THRESHOLD=300 # shutdown only if no running tasks for 5 consecutive minutes
ELAPSED=0
IDLE_SECONDS=0
echo "$(date): PBS shutdown watcher started"
# Wait for at least one backup task to appear first (max 30 min)
echo "$(date): Waiting for backup jobs to start..."
for i in $(seq 1 30); do
SEEN=$(proxmox-backup-manager task list --limit 100 2>/dev/null | grep -c "backup")
if [ "$SEEN" -gt 0 ]; then
echo "$(date): Backup jobs detected. Starting idle monitor."
break
fi
sleep 60
done
# Now monitor until idle for IDLE_THRESHOLD seconds
while [ $ELAPSED -lt $MAX_WAIT ]; do
RUNNING=$(proxmox-backup-manager task list --limit 100 2>/dev/null \
| grep -c " running " || echo 0)
if [ "$RUNNING" -gt 0 ]; then
# Task is running — reset idle counter
IDLE_SECONDS=0
echo "$(date): $RUNNING task(s) running. Idle timer reset."
else
# No running tasks — increment idle counter
IDLE_SECONDS=$((IDLE_SECONDS + INTERVAL))
echo "$(date): No active tasks. Idle for ${IDLE_SECONDS}s / ${IDLE_THRESHOLD}s"
if [ "$IDLE_SECONDS" -ge "$IDLE_THRESHOLD" ]; then
echo "$(date): Idle threshold reached. Shutting down."
/sbin/shutdown -h now
exit 0
fi
fi
sleep $INTERVAL
ELAPSED=$((ELAPSED + INTERVAL))
done
echo "$(date): Max wait time reached. Forcing shutdown."
/sbin/shutdown -h now
EOF
chmod +x /usr/local/sbin/pbs-auto-shutdown.sh
⚠️ This script calls
shutdown -h now— it will power off your PBS machine without any additional confirmation. Test it manually first before enabling the timer.
Now create the systemd timer that starts the watcher 8 minutes after boot (giving PBS time to receive and start the backup job from Proxmox VE):
cat > /etc/systemd/system/pbs-auto-shutdown.service << 'EOF'
[Unit]
Description=Shutdown PBS after backup tasks complete
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/sbin/pbs-auto-shutdown.sh
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/systemd/system/pbs-auto-shutdown.timer << 'EOF'
[Unit]
Description=Start PBS shutdown watcher 8 min after boot
[Timer]
OnBootSec=8min
Unit=pbs-auto-shutdown.service
[Install]
WantedBy=timers.target
EOF
# Enable the timer
systemctl daemon-reload
systemctl enable pbs-auto-shutdown.timer
# Verify
systemctl list-timers pbs-auto-shutdown.timer
ℹ️ The
proxmox-backup-manager task listoutput is a plain table. The script looks for the wordrunningin the status column — confirmed working on PBS 4.1.10.
Step 6 — Test the Full Proxmox Backup Server Automation Flow 🧪
Test the shutdown script logic without actually shutting down:
# Create a test version with shutdown replaced by echo
sed 's|/sbin/shutdown -h now|echo ">>> WOULD SHUTDOWN HERE <<<"|g' \
/usr/local/sbin/pbs-auto-shutdown.sh > /tmp/pbs-shutdown-test.sh
chmod +x /tmp/pbs-shutdown-test.sh
# Run the test version and watch output
/tmp/pbs-shutdown-test.sh
This runs the full script logic but prints >>> WOULD SHUTDOWN HERE <<< instead of actually powering off. Only after confirming the logic works correctly should you use the real script.
Full flow test:
- Shut down PBS manually
- In HA → Developer Tools → Actions → call
button.pressonbutton.pbs_power_button - PBS boots → backup job triggers → shutdown watcher starts → PBS powers off after backup
Once this works reliably, the Proxmox Backup Server automation is complete and fully hands-off — hardware, firmware, and HA all working together. ✅
The Complete Picture 🗺️
Here’s what the full Proxmox Backup Server automation looks like end-to-end. This is exactly how the Proxmox Backup Server automation runs in my homelab every morning:
- 07:55 — HA trigger fires → checks
electricity_absence→ if"off", pressesbutton.pbs_power_button - 07:55 — ESP32-S3 pulses GPIO4 → transistor closes PWR_SW for 400ms → PBS boots
- 08:00 — Proxmox VE backup job starts, PBS is already up and ready
- 08:03 — systemd timer fires 8 min after boot, shutdown watcher starts monitoring
- 08:20 — Proxmox VE backup job runs, transfers all LXC containers to PBS datastore
- 08:40 — All backups complete, watcher detects idle for 2 consecutive checks
- 08:42 — PBS shuts down automatically 🔌
No power wasted. No manual intervention. And if the power was out at 08:00 — nothing starts, your UPS battery stays intact.
If you missed Part 1 where we set up the hardware and installed PBS, check it out here. For more Proxmox guides, see how I set up WireGuard VPN on Proxmox and the Proxmox post-install script I use on every fresh node.
🔗 External Resources
Proxmox VE — official documentation
Proxmox Backup Server — official documentation
