Files
docs/Scripts/Bash/ProxmoxVE/Deeplab Rollback Script.md
Nicole Rappe 805eca511c
All checks were successful
GitOps Automatic Deployment / GitOps Automatic Deployment (push) Successful in 7s
Update Scripts/Bash/ProxmoxVE/Deeplab Rollback Script.md
2025-10-17 03:39:57 -06:00

1.3 KiB

Purpose

This script is ran via cronjob on cluster-node-02 at midnight to rollback the deeplab environment automatically to a previous snapshot nightly.

Bash Script

#!/usr/bin/env bash
# ProxmoxVE Nightly DeepLab Rollback Script

SNAPNAME="ROLLBACK"

DC=140
WIN10=141
WIN11=111
ALL=("$DC" "$WIN10" "$WIN11")

log(){ echo "[$(date '+%F %T')] $*"; }

# Force Stop DeepLab VMs
for id in "${ALL[@]}"; do
  log "Force stopping VM $id"
  /usr/sbin/qm stop "$id" || true
done

# Rollback Snapshots
for id in "${ALL[@]}"; do
  log "Rolling back VM $id to snapshot $SNAPNAME"
  /usr/sbin/qm rollback "$id" "$SNAPNAME"
done

# Start DC
log "Starting DC ($DC)"
/usr/sbin/qm start "$DC"

# Wait 2 minutes
log "Waiting 2 minutes for DC to initialize..."
sleep 120

# Start Win10 + Win11
log "Starting WIN10 ($WIN10) and WIN11 ($WIN11)"
/usr/sbin/qm start "$WIN10" &
/usr/sbin/qm start "$WIN11" &
wait

log "Lab Rollback Complete."

Crontab Scheduling

Type crontab -e to add an entry to run the job at midnight every day.

=== "With Logging"

``` sh
0 0 * * * /root/deeplab-rollback.sh >> /var/log/deeplab-rollback.log 2>&1
```

=== "Without Logging"

``` sh
0 0 * * * /root/deeplab-rollback.sh 2>&1
```