summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent <laurent@pogopixels.com>2013-12-06 08:39:40 -0800
committerLaurent <laurent@pogopixels.com>2013-12-06 08:39:40 -0800
commit9a87c1d4e4de4c956689e7a9169c452b5df0923e (patch)
tree2e52c7afd3bc5af934b50f324bb61acdfa8e73a4
parentc854cd17c6c6c76de4ec2cae365e0b6fd9e7f1cf (diff)
parent808767dc66ae77b044aab5df98daf39bc96d7f5a (diff)
Merge pull request #23 from robru/simplify-logfiles
Simplify logfile parsing and drop unreachable codepath.
-rw-r--r--rsync_tmbackup.sh21
1 files changed, 4 insertions, 17 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index c49d8f2..b2131c9 100644
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -221,32 +221,19 @@ while : ; do
# -----------------------------------------------------------------------------
# TODO: find better way to check for out of space condition without parsing log.
- grep --quiet "No space left on device (28)" "$LOG_FILE"
- NO_SPACE_LEFT="$?"
- if [ "$NO_SPACE_LEFT" != "0" ]; then
- # This error might also happen if there is no space left
- grep --quiet "Result too large (34)" "$LOG_FILE"
- NO_SPACE_LEFT="$?"
- fi
+ NO_SPACE_LEFT="$(grep "No space left on device (28)\|Result too large (34)" "$LOG_FILE")"
rm -- "$LOG_FILE"
- if [ "$NO_SPACE_LEFT" == "0" ]; then
+ if [ -n "$NO_SPACE_LEFT" ]; then
fn_log_warn "No space left on device - removing oldest backup and resuming."
- BACKUP_FOLDER_COUNT=$(fn_find_backups | wc -l)
- if [[ "$BACKUP_FOLDER_COUNT" -lt "2" ]]; then
+ if [[ "$(fn_find_backups | wc -l)" -lt "2" ]]; then
fn_log_error "No space left on device, and no old backup to delete."
exit 1
fi
- OLD_BACKUP_PATH="$(fn_find_backups | tail -n 1)"
- if [ -z "$OLD_BACKUP_PATH" ]; then
- fn_log_error "No space left on device, and cannot get path to oldest backup to delete."
- exit 1
- fi
-
- fn_expire_backup "$OLD_BACKUP_PATH"
+ fn_expire_backup "$(fn_find_backups | tail -n 1)"
# Resume backup
continue