From 9a9d8fe9b9e68a8963907c9e3c3ac83d6e3c2021 Mon Sep 17 00:00:00 2001 From: Will Budic Date: Sun, 15 Feb 2026 20:51:37 +1100 Subject: [PATCH] fix: upd. for ls to use the -t flag. --- linux-B_L_R_via_sshfs/list.sh | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/linux-B_L_R_via_sshfs/list.sh b/linux-B_L_R_via_sshfs/list.sh index 4ae89dd..a01a825 100755 --- a/linux-B_L_R_via_sshfs/list.sh +++ b/linux-B_L_R_via_sshfs/list.sh @@ -13,12 +13,12 @@ echo -e " This is an backup archive restore list creator, use this program from echo -e " Backup location is DEST_SERVER='$DEST_SERVER'" echo -e " Restore location is PWD='`pwd`'" echo -e "--------------------------------------------------------------------------------------------------------------" -echo -e "Syntax: $0 {-target=/some/path} {-keep} {restore.lst}\n" +echo -e "Syntax: $0 {{-target=/some/path} {--tar} | {restore.lst}\n}" echo "After listing, to restore from the backup, use the list with the restore shell script." echo "Like: $SRC_DIR/restore.sh ./restore.lst" echo "To restore from a local drive or mount:" echo "$SRC_DIR/restore.sh --target=/mnt/$user/samsung ./restore.lst" -echo -e "Usage: $0 -keep - With -keep option so an previously created default named restore.lst will not be deleted.\n" +echo -e "Usage: $0 --tar - Instruction to generate and text tar listing from latest archive. In text format to be viewed.\n" [[ "$1" == '-?' || "$1" == '-h' ]] && exit; echo -e "Processing from config: $CONFIG_FILE" @@ -48,24 +48,21 @@ fi if [[ ! -z "$1" && "$1" == "--tar" ]] then - BACKUP_FILE=$(ls $TARGET/$THIS_MACHINE-*.$EXT_ENC|tail -n 1) + BACKUP_FILE=$(ls -t $TARGET/$THIS_MACHINE-*.$EXT_ENC | head -n 1) + echo -e "Backup: $BACKUP_FILE\n" gpg --decrypt --batch --passphrase $GPG_PASS $BACKUP_FILE | pv -N "Status" -pw 80 | tar -Jtv \ > "$BACKUP_FILE.list" - echo -e "Tar list of -> $BACKUP_FILE\n" + echo -e "Crated tar list of -> $BACKUP_FILE\n" exit fi -INDEX=$(ls -lh $TARGET/$THIS_MACHINE-*.$EXT_LST |sort -r|head -n 1); +INDEX=$(ls -lht $TARGET/$THIS_MACHINE-*.$EXT_LST | head -n 1); if [[ -z $INDEX ]] then echo -e "FAILED to access target backup directory!\n" exit 0 fi - - - - INDEX_FILE=$(echo "$INDEX" | awk '{print $9}') echo -e "Listing $INDEX_FILE\n" sel=$(xzcat "$INDEX_FILE" | sort -f -u | fzf --multi --header "Listing: $INDEX Config: $CONFIG_FILE") @@ -81,10 +78,10 @@ done echo -e "Restore list contents check:" # Following is an good example why uvars are needed, bash can only forward $variables to spawn shells global variables. -# This is what we are doing with the following statment. Or we could write this whole and other scripts in perl? :) +# This is what we are doing with the following statement. Or we could write this whole and other scripts in perl? :) cat restore.lst | sort -u | while read n do - #Display exisiting directory if selected. + #Display existing directory if selected. if [[ -d ~/$n ]] then echo -e "-------------------------------" @@ -100,10 +97,11 @@ done if [[ $(~/uvar.sh -s /var/tmp -r "BCK_LST_CHK") -eq 1 ]] then echo -e "Warning - existing directories that have been found and listed above." \ -"\n During an restore are not synched, this will overwite existing local files or leave unneeded files." +"\n During an restore are not synched, this will overwrite existing local files or leave unneeded files." ~/uvar.sh -d "BCK_LST_CHK" > /dev/null fi exit -# This script originated from https://github.com/wbudic/B_L_R_via_sshfs -# Required uvar.sh be installed in home directory, located at: https://github.com/wbudic/wb-shell-scripts \ No newline at end of file +# This script originated from : https://lifelog.hopto.org/gitweb/?p=wb-shell-scripts.git +# older versions https://github.com/wbudic/B_L_R_via_sshfs + -- 2.34.1