@@ -355,27 +355,18 @@ run_restore_mode() {
355
355
if [[ -n " $dir_choice " ]]; then break ;
356
356
else echo " Invalid selection. Please try again." ; fi
357
357
done
358
- PS3=" #? "
358
+ PS3=" #? "
359
359
local full_remote_source=" "
360
360
local default_local_dest=" "
361
361
local item_for_display=" "
362
362
local restore_path=" "
363
363
local is_full_directory_restore=false
364
364
if [[ " $dir_choice " == " $RECYCLE_OPTION " ]]; then
365
365
print_header " Browse Recycle Bin"
366
+ local date_folders=()
366
367
local remote_recycle_path=" ${BOX_DIR%/ } /${RECYCLE_BIN_DIR%/ } "
367
- local date_folders; date_folders=$( ssh " ${SSH_OPTS_ARRAY[@]} " " ${SSH_DIRECT_OPTS[@]} " " $BOX_ADDR " " ls -1 \" $remote_recycle_path \" " 2> /dev/null) || true
368
- local valid_folders=()
369
- for f in $date_folders ; do
370
- case " $f " in
371
- [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9])
372
- valid_folders+=( " $f " )
373
- ;;
374
- esac
375
- done
376
- date_folders=(" ${valid_folders[@]} " )
368
+ mapfile -t date_folders < <( ssh " ${SSH_OPTS_ARRAY[@]} " " ${SSH_DIRECT_OPTS[@]} " " $BOX_ADDR " " ls -1 \" $remote_recycle_path \" " 2> /dev/null | grep -E ' ^[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{6}$' )
377
369
if [[ ${# date_folders[@]} -eq 0 ]]; then
378
- echo " ❌ No validly-named backup folders found in the recycle bin." >&2 ; return 1
379
370
fi
380
371
printf " ${C_YELLOW} Select a backup run (date_time) to browse:${C_RESET} \n"
381
372
PS3=" Your choice: "
@@ -410,6 +401,11 @@ run_restore_mode() {
410
401
case " $choice " in
411
402
entire) is_full_directory_restore=true; break ;;
412
403
specific)
404
+ local relative_path_browse=" ${dir_choice#* ./ } "
405
+ local remote_browse_source=" ${REMOTE_TARGET}${relative_path_browse} "
406
+ print_header " Files available in ${dir_choice} (showing first 20)"
407
+ rsync -r -n --out-format=' %n' -e " $SSH_CMD " " $remote_browse_source " . 2> /dev/null | head -n 20 || echo " No files found for this backup set."
408
+ printf " %b--------------------------------------------------------%b\n" " ${C_BOLD} " " ${C_RESET} "
413
409
printf -v specific_path_prompt " Enter the path relative to '%s' to restore (e.g., subfolder/file.txt): " " $dir_choice " ; printf " ${C_YELLOW} %s${C_RESET} " " $specific_path_prompt " ; read -er specific_path
414
410
if [[ " $specific_path " == /* || " $specific_path " =~ (^| /)\.\. (/| $) ]]; then
415
411
echo " ❌ Invalid restore path: must be relative and contain no '..'" >&2 ; return 1
0 commit comments