aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2018-12-01 04:18:54 +0100
committerEinhard Leichtfuß <alguien@respiranto.de>2018-12-01 04:18:54 +0100
commitb3352cb42a4d6e98f8b6203fe427fbd9959f3c2e (patch)
tree927a65bc301046c6adf82f3540125506748c75ff
parent4e743f361c62ca9a0eac47b80a1313b54454e425 (diff)
downloadrsync-backup-b3352cb42a4d6e98f8b6203fe427fbd9959f3c2e.tar.gz
rsync-backup-b3352cb42a4d6e98f8b6203fe427fbd9959f3c2e.tar.xz
Fix by_number/
Before, it did not work correctly for >= 100 backups. (There would only be prepended 0 or nothing to the unpadded number.)
-rw-r--r--TODO2
-rwxr-xr-xrsync-backup.sh16
2 files changed, 11 insertions, 7 deletions
diff --git a/TODO b/TODO
index 5213c3f..b62b497 100644
--- a/TODO
+++ b/TODO
@@ -14,6 +14,8 @@
- Allow resuming of backups.
`- See rsync's `--ignore-existing' flag
- Shell completion of configured backup paths.
+- Use `local'.
+- Better error handling on failure (of rsync).
# -- PROBLEMS -- #
- rsync bug: https://bugzilla.samba.org/show_bug.cgi?id=13445
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