diff --git a/Scripts/Bash/ProxmoxVE/Deeplab Rollback Script.md b/Scripts/Bash/ProxmoxVE/Deeplab Rollback Script.md new file mode 100644 index 0000000..3a544a0 --- /dev/null +++ b/Scripts/Bash/ProxmoxVE/Deeplab Rollback Script.md @@ -0,0 +1,62 @@ +## 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 + +```sh title="/root/deeplab-rollback.sh" +#!/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 + ``` +```sh title="crontab -e"