host-backup.sh: Added "ALL" option and include timestamp in backup filename (#8276)

* Update host-backup.sh

added an "all" button to include all folders instead of clicking every folder by itself

* Update host-backup.sh

added a timestamp in the filename incase the user wants to make several backups on the same time.
Otherweise the newest backup will overwrite the earlier one.
This commit is contained in:
stumpyofpain 2025-10-11 17:20:06 +02:00 committed by GitHub
parent 9b4812df33
commit f81e50c430
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,6 +41,7 @@ function perform_backup {
# Build a list of directories for backup
local CTID_MENU=()
CTID_MENU=("ALL" "Backup all folders" "OFF")
while read -r dir; do
CTID_MENU+=("$(basename "$dir")" "$dir " "OFF")
done < <(ls -d "${DIR}"*)
@ -52,7 +53,13 @@ function perform_backup {
"\nSelect what files/directories to backup:\n" 16 $(((${#DIRNAME} + 2) + 88)) 6 "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || return
for selected_dir in ${HOST_BACKUP//\"/}; do
selected_directories+=("${DIR}$selected_dir")
if [[ "$selected_dir" == "ALL" ]]; then
# if ALL was chosen, secure all folders
selected_directories=("${DIR}"*/)
break
else
selected_directories+=("${DIR}$selected_dir")
fi
done
done
@ -62,7 +69,7 @@ function perform_backup {
read -p "Press ENTER to continue..."
header_info
echo "Working..."
tar -czf "$BACKUP_PATH$BACKUP_FILE-$(date +%Y_%m_%d).tar.gz" --absolute-names "${selected_directories[@]}"
tar -czf "$BACKUP_PATH$BACKUP_FILE-$(date +%Y_%m_%dT%H_%M).tar.gz" --absolute-names "${selected_directories[@]}"
header_info
echo -e "\nFinished"
echo -e "\e[1;33m \nA backup is rendered ineffective when it remains stored on the host.\n \e[0m"