fix some incorrect variable names

This commit is contained in:
adam committed 2026-01-14 09:45:58 +00:00
1 parent 5e07f58248
commit 4a0a1ff9a7
1 file changed
+7 -5
+7 -5
View File
@@ -17,10 +17,10 @@ main() {
x) x)
declare -g EXTENSION declare -g EXTENSION
if [[ "${OPTARG,,}" == 'none' ]]; then if [[ "${OPTARG,,}" == 'none' ]]; then
EXTENTION="" EXTENSION=""
else else
command -v "$OPTARG" >/dev/null 2>&1 || { echo "$OPTARG command not found"; exit 1; } command -v "$OPTARG" >/dev/null 2>&1 || { echo "$OPTARG command not found"; exit 1; }
EXTENTION="${OPTARG,,}" EXTENSION="${OPTARG,,}"
fi fi
declare -g COMPRESSION="$OPTARG" declare -g COMPRESSION="$OPTARG"
@@ -91,9 +91,11 @@ start_backup() {
local vm=$1 local vm=$1
local backup_base="$2" local backup_base="$2"
local compression="${COMPRESSION:-none}" local compression="${COMPRESSION:-none}"
local ext="${EXTENTION}" ; [[ -n "$ext" ]] && ext=".${ext}" local ext="${EXTENSION}" ; [[ -n "$ext" ]] && ext=".${ext}"
local destination="${backup_base}/${vm}" local destination="${backup_base}/${vm}"
local backup_name="${vm}_$(date +"%Y-%m-%d_%H-%M-%S").tar${ext}"
local backup_name
backup_name="${vm}_$(date +"%Y-%m-%d_%H-%M-%S").tar${ext}"
[[ -d "$backup_base" ]] || { echo "${backup_base} is not a directory"; exit 1; } [[ -d "$backup_base" ]] || { echo "${backup_base} is not a directory"; exit 1; }
[[ -d "$destination" ]] || mkdir "$destination" [[ -d "$destination" ]] || mkdir "$destination"
@@ -109,7 +111,7 @@ prune_backups() {
mapfile -t backup_files < <(find "$backup_directory" -maxdepth 1 -type f -printf '%T@ %p\n' | sort -n | head -n "-${files_to_keep}" | cut -d' ' -f2-) mapfile -t backup_files < <(find "$backup_directory" -maxdepth 1 -type f -printf '%T@ %p\n' | sort -n | head -n "-${files_to_keep}" | cut -d' ' -f2-)
if [[ ${#backup_files[@]} -gt 0 ]]; then if [[ ${#backup_files[@]} -gt 0 ]]; then
echo "Removing ${#qcow2_files[@]} old backup files for $vm (keeping last $total_files_to_keep files)" echo "Removing ${#backup_files[@]} old backup files for $vm (keeping last $files_to_keep files)"
printf '%s\0' "${backup_files[@]}" | xargs -0 rm -fv printf '%s\0' "${backup_files[@]}" | xargs -0 rm -fv
else else
echo "No old backups to remove for $vm" echo "No old backups to remove for $vm"