From 9408e3e88a3f0e2f50c6dbb1aa0c02cd22ac9401 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 11 Sep 2019 13:46:06 +0200 Subject: backup-progress: time out `du` after $du_timeout seconds --- backup-progress.in | 10 ++++++++-- backup.conf | 3 +++ 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 -- cgit v1.2.3-70-g09d2