Proxmox VM Auto-Upgrade Script (qm + vzdump) with Network Tests and Auto-Restore

Proxmox VM Auto-Upgrade Script (qm + vzdump) with Network Tests and Auto-Restore

This article describes a simple (but effective) automation script for Proxmox VE that:

  • creates a backup of a VM (optional),
  • starts the VM if it was originally stopped,
  • runs apt upgrade + reboot inside the VM,
  • performs network tests before and after the update,
  • restores from backup automatically if tests fail (optional),
  • shuts down the VM again if it was originally stopped.

Where to download the script

You can download the script directly from my website:

soban.pl/bash/upgrade_proxmox_qm.sh

Required folders

Before you run anything, create two folders for scripts and logs:

Install the script

Download the file into /root/automate_scripts/ and make it executable:

How it works (high level)

  • Backup (vzdump snapshot + zstd) is executed first (if enabled).
  • If the VM was stopped, the script starts it and waits WAIT_TIME seconds.
  • Runs network tests BEFORE update:
  • Executes apt update/upgrade/dist-upgrade/autoremove/clean and finally reboots the VM.
  • Waits again (WAIT_TIME) and runs the same tests AFTER update.
  • If tests fail and a backup exists, it performs qmrestore automatically.
  • If the VM was originally stopped, it shuts down the VM at the end.

Usage

The script expects exactly two arguments:

  • VMID – the Proxmox VM ID
  • TIME_SEC – how long to wait after start/reboot (in seconds)

Tip: choose a WAIT_TIME that matches your VM boot time and apt upgrade duration. Typical values are 300 to 1000 seconds depending on the VM.

Full script (for reference)

If you prefer to keep everything in one place, below is the full script exactly as used in this setup:

Cron jobs (weekly schedule + per-VM logs)

Below is an example crontab that runs upgrades once a week (different VM each weekday) and writes separate logs to /root/logs/.

Edit root crontab:

Paste rules like these (comments in English):

Quick checks / troubleshooting

  • Make sure root can SSH into the VM by hostname (the script uses ssh root@<vm-hostname>).
  • Make sure DNS (or /etc/hosts) resolves the VM hostname correctly from the Proxmox host.
  • If apt needs user interaction, ensure your VMs are set up for non-interactive upgrades (or pin/hold packages that prompt).

That’s it. Drop the script into /root/automate_scripts/, send logs into /root/logs/, and your weekly VM maintenance becomes mostly fire-and-forget.

Dell WD19/WD19S: firmware update on Proxmox/Debian without USB timeouts (fwupd + autosuspend fix)


If you’re trying to update the firmware of a Dell WD19/WD19S docking station on Proxmox (or Debian) using fwupdmgr, you may hit the classic Operation timed out error during the Erasing… stage. In practice, the update fails due to USB power management (autosuspend). Below you’ll find a simple, effective fix and a ready-to-run script you can use on a server or laptop.

Symptoms

Most commonly, during a dock firmware update (WD19/WD19S), you’ll see an error similar to:

At this point, fwupdmgr may show the WD19S device as Update State: Failed or keep reporting pending activation, but the flash process never completes.

Why does this happen?

During flashing, the dock performs long-running operations. If the system tries to save power on USB (autosuspend), control transfers can fail. The result is a timeout exactly during the flash bank erase stage (erase bank).

Quick fix: disable USB autosuspend during the update

The simplest solution is to temporarily set autosuspend to -1 (disabled). This setting lasts until reboot (unless you make it permanent in the kernel cmdline), but it’s more than enough for the update process.

Then run the firmware update:

After the update: “pending activation” and unplug requirement

After a successful firmware installation for WD19/WD19S, fwupdmgr often prints the following message:

Do the following in this exact order:

  • Unplug the USB-C cable from the dock (from the laptop).
  • (Optional) Unplug the dock power for 10–15 seconds and plug it back in.
  • Plug the USB-C cable back in.
  • Run the activation step:

Finally, verify the status:

Ready-to-use script: install + update + autosuspend disable (with restore)

Below is a ready-to-run script that:

  • installs fwupd
  • refreshes LVFS metadata
  • temporarily disables USB autosuspend (so WD19S won’t fail with timeouts)
  • runs firmware updates
  • restores the previous autosuspend value afterwards (even if the update fails)

You can copy the script directly from this article, but if you prefer a faster way, you can download it from:

https://soban.pl/bash/dell_updage.sh

Example download and run:

If you want to preview the script before running it:

If you don’t have less installed:

Script (full content)

Running the script

The simplest way:

FAQ & tips

  • The update still fails? Disconnect all peripherals from the dock (monitors/LAN/USB), leave only power and USB-C, do a hard reset of the dock (unplug power for 30s), and try again.
  • “pending activation” after update – this is normal for WD19/WD19S. You must unplug USB-C, plug it back in, then run fwupdmgr activate.
  • Does this update the laptop BIOS? Not always. fwupdmgr shows “System Firmware” (BIOS/UEFI) separately from the dock. This article focuses on the dock and the USB timeout issue.

Summary

If Dell WD19/WD19S firmware updates fail on Proxmox/Debian during the Erasing… stage, in most cases it’s enough to disable USB autosuspend temporarily. The script above does that automatically and restores the previous setting afterwards, so your system keeps working normally.