From 95380a96b9496746414a20e41b83d8adf947a4b2 Mon Sep 17 00:00:00 2001 From: "Gaunt, John" Date: Thu, 18 Jan 2018 12:15:35 -0500 Subject: [PATCH] Update rclone.sh --- rclone.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/rclone.sh b/rclone.sh index d6e0232..070ae48 100755 --- a/rclone.sh +++ b/rclone.sh @@ -26,15 +26,17 @@ function gzipVMbackups { # loop through VM backups and tar/gzip them to single file for dir in /mnt/data-pool/esxi/backups/*/*/; do - # get the folder name of the backup - base=$(basename "${dir}") - # had to cd into the directoy since tar -C $dir was not working for me with relative path - cd ${dir%/*/} - # create the tar and pipe into pigz for multi-threaded gzip - tar cf - "${base}" | pigz > "${dir%/}.gz" - # if the tar/gzip was successful, delete the backup directory - if [ $? -eq 0 ] && [ -f "${dir%/}.gz" ]; then - rm -rf "${dir}" + if [ ! -z "$dir" ]; + # get the folder name of the backup + base=$(basename "${dir}") + # had to cd into the directoy since tar -C $dir was not working for me with relative path + cd "${dir%/*/}" + # create the tar and pipe into pigz for multi-threaded gzip + tar cf - "${base}" | pigz > "${dir%/}.gz" + # if the tar/gzip was successful, delete the backup directory + if [ $? -eq 0 ] && [ -f "${dir%/}.gz" ]; then + rm -rf "${dir}" + fi fi done }