Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- lastsnap_location=
- # For VMs: /root/vm_lastsnap
- # For CTs: /root/ct_lastsnap
- list_location=
- # For VMs: /etc/pve/nodes/pve/qemu-server
- # For CTs: /etc/pve/lxc
- snap_command=
- # For VMs: "qm snapshot"
- # For CTs: "pct snapshot"
- snap_suffix="auto_$(date +%Y%m%d) -description \"Autosnapped at $(date +%H:%M:%S)\""
- snapped=false
- first=false
- if [ -f $lastsnap_location ]; then
- lastsnap=`cat $lastsnap_location`
- else
- lastsnap=0
- fi
- for i in `ls $list_location | egrep -o '[0-9]{3,}'`; do
- if [[ $first -eq false ]]; then
- first=$i
- fi
- if (( $i > $lastsnap )); then
- echo $snap_command $i $snap_suffix | /bin/sh
- snapped=true
- echo $i > $lastsnap_location
- break
- fi
- done
- if ! $snapped; then
- echo $snap_command $first $snap_suffix | /bin/sh
- echo $first > $lastsnap_location
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement