Why test guests pile up

Test guests are easy to create and easy to forget. Each one keeps using RAM or disk, may be included in backups, and often stops getting updates. A simple rule fixes most of it: every test guest gets an expiry date the moment it is created.

  1. Tag at creationexpires-YYYY-MM-DD
  2. List the expiredweekly script
  3. Shut downqm shutdown
  4. Grace periodfor example two weeks
  5. Back up, then destroyvzdump, --purge
Shutdown is reversible and deletion is not, so there is always a grace period in between.

Step 1: Tag every test guest with an expiry date

Proxmox lets you put tags on VMs and containers. Use a tag with a date in it:

qm set 9100 --tags expires-2026-12-31
pct set 9101 --tags expires-2026-12-31

--tags replaces the whole list. To keep existing tags, include them, separated by semicolons: --tags 'expires-2026-12-31;web'. The qm manual and pct manual list every option.

Step 2: List the expired guests

This script reads every guest in the cluster and prints the ones whose date has passed. It only reads:

pvesh get /cluster/resources --type vm --output-format json | python3 -c '
import sys, json, re, datetime
today = datetime.date.today()
for g in json.load(sys.stdin):
    m = re.search(r"expires-(\d{4}-\d{2}-\d{2})", g.get("tags", ""))
    if m and datetime.date.fromisoformat(m.group(1)) < today:
        print(g["vmid"], g["name"], g["type"], g["status"], m.group(1))'

Run it weekly, by hand or from cron, and send yourself the output.

Step 3: Shut down first, delete later

A clean shutdown is reversible and a deletion is not. Shut expired guests down and leave them for a grace period, such as two weeks, before you decide:

qm shutdown 9100
pct shutdown 9101

When you are sure, take a last backup and then destroy the guest:

vzdump 9100 --storage local
qm destroy 9100 --purge

Renewing a guest you still need

Change the date in the tag and it is safe again. That makes extending a test one command, instead of a guess about whether anyone still wants it.

Doing it automatically

Pontavia's VM Lease Manager ($39) is an n8n workflow built on this idea. Tag a test VM or container expires-2026-12-31 and you get a heads-up before the date. After a grace period the guest is shut down cleanly. You renew by changing the tag. It never deletes anything, is opt-in per guest, and is report-only until you switch it on. You choose the warning days and the grace days. It is also in the $89 Ops 3-Pack.

Frequently asked questions

Can I tag VMs and containers in Proxmox?

Yes. Proxmox VE supports tags on both. Set them with qm set <id> --tags ... for VMs and pct set <id> --tags ... for containers, or in the web interface.

Does the --tags option add to existing tags?

No, it replaces the whole list. Include the tags you want to keep, separated by semicolons.

Why shut an expired guest down instead of deleting it?

A shutdown can be undone by starting the guest again, a deletion cannot. A grace period catches the guest someone still needed.

Should I back up a test VM before destroying it?

If there is any chance you will want it back, yes. Run vzdump <id> first, then destroy the guest.

Questions about your own setup? Send a message or book a free 15-minute call.