mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-11-05 10:52:49 +00:00
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:
@@ -41,6 +41,7 @@ function perform_backup {
|
|||||||
|
|
||||||
# Build a list of directories for backup
|
# Build a list of directories for backup
|
||||||
local CTID_MENU=()
|
local CTID_MENU=()
|
||||||
|
CTID_MENU=("ALL" "Backup all folders" "OFF")
|
||||||
while read -r dir; do
|
while read -r dir; do
|
||||||
CTID_MENU+=("$(basename "$dir")" "$dir " "OFF")
|
CTID_MENU+=("$(basename "$dir")" "$dir " "OFF")
|
||||||
done < <(ls -d "${DIR}"*)
|
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
|
"\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
|
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
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -62,7 +69,7 @@ function perform_backup {
|
|||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
echo "Working..."
|
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
|
header_info
|
||||||
echo -e "\nFinished"
|
echo -e "\nFinished"
|
||||||
echo -e "\e[1;33m \nA backup is rendered ineffective when it remains stored on the host.\n \e[0m"
|
echo -e "\e[1;33m \nA backup is rendered ineffective when it remains stored on the host.\n \e[0m"
|
||||||
|
|||||||
Reference in New Issue
Block a user