summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-09-11 13:46:06 +0200
committerErich Eckner <git@eckner.net>2019-09-11 13:46:06 +0200
commit9408e3e88a3f0e2f50c6dbb1aa0c02cd22ac9401 (patch)
tree7ffb4b0bd74f66c768396ccddb1e0134cafbd4cf
parent0ac8bd369c3247b0687c0bdd20f8275d5c545022 (diff)
downloadhardlinkedBackups-9408e3e88a3f0e2f50c6dbb1aa0c02cd22ac9401.tar.xz
backup-progress: time out `du` after $du_timeout seconds
-rwxr-xr-xbackup-progress.in10
-rw-r--r--backup.conf3
2 files changed, 11 insertions, 2 deletions
diff --git a/backup-progress.in b/backup-progress.in
index 90492fb..4e67f92 100755
--- a/backup-progress.in
+++ b/backup-progress.in
@@ -26,13 +26,19 @@ for backupID in "${!backups[@]}"; do
| tail -n1
)
last_size=$(
- du -sb "${dir}/${last}" \
+ timeout ${du_timeout} du -sb "${dir}/${last}" \
| awk '{print $1}'
)
+ if [ -z "${last_size}" ]; then
+ last_size='4096'
+ fi
current_size=$(
- du -sb "${dir}/aktuell" \
+ timeout ${du_timeout} du -sb "${dir}/aktuell" \
| awk '{print $1}'
)
+ if [ -z "${current_size}" ]; then
+ current_size='0'
+ fi
size="${current_size}"
decimal=''
for unit in '' k M G T P Y; do
diff --git a/backup.conf b/backup.conf
index 8d7fd4e..63e3ec5 100644
--- a/backup.conf
+++ b/backup.conf
@@ -37,3 +37,6 @@ recognSubdirRegex="home\|boot\|root\|erich"
# directory for caching valuable information in backup-statistics
cacheDir="/path/to/cache/directory"
+
+# timeout for `du` in backup-progress [seconds]
+du_timeout=10