Created
September 3, 2020 19:48
-
-
Save pierew/eb6d3bff6819682bb3feca2d037904a9 to your computer and use it in GitHub Desktop.
Proxmox VE Autosnapshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TODAY_DAY=$(date +%a | tr '[:upper:]' '[:lower:]') | |
echo "Reading Container in /pools/LXC-Backup" | |
for VMID in $(pvesh get /pools/LXC-Backup/ --output-format json-pretty | jq '.members | .[].vmid'); | |
do | |
if [[ $(pct list | grep $VMID) == *"$VMID"* ]] | |
then | |
echo "CT $VMID - Delete Snapshot" | |
pct delsnapshot $VMID "auto_snap_$TODAY_DAY" | |
echo "CT $VMID - Snapshot" | |
pct snapshot $VMID "auto_snap_$TODAY_DAY" | |
fi | |
done | |
echo "" | |
echo "Reading VMs in /pools/VM-Backup" | |
for VMID in $(pvesh get /pools/VM-Backup/ --output-format json-pretty | jq '.members | .[].vmid'); | |
do | |
if [[ $(pct list | grep $VMID) == *"$VMID"* ]] | |
then | |
echo "VM $VMID - Delete Snapshot" | |
qm delsnapshot $VMID "auto_snap_$TODAY_DAY" | |
echo "VM $VMID - Snapshot" | |
qm snapshot $VMID "auto_snap_$TODAY_DAY" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment