Skip to content

Commit f81e50c

Browse files
authored
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.
1 parent 9b4812d commit f81e50c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/pve/host-backup.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function perform_backup {
4141

4242
# Build a list of directories for backup
4343
local CTID_MENU=()
44+
CTID_MENU=("ALL" "Backup all folders" "OFF")
4445
while read -r dir; do
4546
CTID_MENU+=("$(basename "$dir")" "$dir " "OFF")
4647
done < <(ls -d "${DIR}"*)
@@ -52,7 +53,13 @@ function perform_backup {
5253
"\nSelect what files/directories to backup:\n" 16 $(((${#DIRNAME} + 2) + 88)) 6 "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || return
5354

5455
for selected_dir in ${HOST_BACKUP//\"/}; do
55-
selected_directories+=("${DIR}$selected_dir")
56+
if [[ "$selected_dir" == "ALL" ]]; then
57+
# if ALL was chosen, secure all folders
58+
selected_directories=("${DIR}"*/)
59+
break
60+
else
61+
selected_directories+=("${DIR}$selected_dir")
62+
fi
5663
done
5764
done
5865

@@ -62,7 +69,7 @@ function perform_backup {
6269
read -p "Press ENTER to continue..."
6370
header_info
6471
echo "Working..."
65-
tar -czf "$BACKUP_PATH$BACKUP_FILE-$(date +%Y_%m_%d).tar.gz" --absolute-names "${selected_directories[@]}"
72+
tar -czf "$BACKUP_PATH$BACKUP_FILE-$(date +%Y_%m_%dT%H_%M).tar.gz" --absolute-names "${selected_directories[@]}"
6673
header_info
6774
echo -e "\nFinished"
6875
echo -e "\e[1;33m \nA backup is rendered ineffective when it remains stored on the host.\n \e[0m"

0 commit comments

Comments
 (0)