Advertisement
Guest User

Untitled

a guest
May 26th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. for b in 512 256 128 64 32 16 8 4; do
  2.   let a=b/2+1
  3.   let f=0 #this flag is set to 1 when we find the 1st snapshot in the range b..a
  4.   for i in $(seq -f'%03g' "${b}" -1 "${a}"); do
  5.     if [ -d "${SNAPSHOT_DST}/${HOST_SRC}/${NAME}.${i}" ]; then
  6.       if [ "${f}" -eq 0 ]; then
  7.         let f=1
  8.       else
  9.         echo "$(date +%Y-%m-%d_%H:%M:%S) Removing ${SNAPSHOT_DST}/${HOST_SRC}/${NAME}.${i} ..."
  10.         [ "${CHATTR}" -eq 1 ] && chattr -R -i "${SNAPSHOT_DST}/${HOST_SRC}/${NAME}.${i}" &>/dev/null
  11.         rm -rf "${SNAPSHOT_DST}/${HOST_SRC}/${NAME}.${i}"
  12.       fi
  13.     fi
  14.   done
  15. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement