From b3352cb42a4d6e98f8b6203fe427fbd9959f3c2e Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Sat, 1 Dec 2018 04:18:54 +0100 Subject: Fix by_number/ Before, it did not work correctly for >= 100 backups. (There would only be prepended 0 or nothing to the unpadded number.) --- rsync-backup.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'rsync-backup.sh') diff --git a/rsync-backup.sh b/rsync-backup.sh index a03da9b..4f33be4 100755 --- a/rsync-backup.sh +++ b/rsync-backup.sh @@ -28,7 +28,7 @@ typeset -A bakpath typeset filter_file_all # Applied after specific filter. typeset -A filter_file -# Default arguments for rsync (-rptoglHS, --timeout, --info). +# Default arguments for rsync (-rptogAXlHS, --timeout, --info). rsync_args=( --recursive --perms --times --owner --group @@ -68,7 +68,7 @@ typeset -i i n # --progress # possibly: --devices --specials # --max-size=SIZE-OF-FILE -# --one-file-system +# --one-file-system # --log-file=FILE --log-file-format=FORMAT # --human-readable # unlikely: --omit-{dir,link}-times --update (!--inplace) --delete @@ -277,12 +277,14 @@ function refresh_symlinks done dirs[$n]="$bakdate" # Set last dir on current. - max_n_zeros=$((${#n} - 1)) - i=1 - while [ $i -le $max_n_zeros ] + + max_digits=${#n} + zeros[max_digits]='' + i=$max_digits-1 + while [ $i -ge 1 ] do - zeros[i]=$(printf '%.s0' {$i..$max_n_zeros}) - i+=1 + zeros[i]=${zeros[i+1]}0 + i+=-1 done i=0 -- cgit v1.2.3