Move more setup code inside loop

This commit is contained in:
Laurent Cozic
2013-11-12 11:14:02 +08:00
parent 84415a3045
commit b481985f2a
+3 -5
View File
@@ -106,6 +106,9 @@ if [ -f "$INPROGRESS_FILE" ]; then
fi fi
fi fi
# Run in a loop to handle the "No space left on device" logic.
while [ "1" ]; do
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Check if we are doing an incremental backup (if previous backup exists) or not # Check if we are doing an incremental backup (if previous backup exists) or not
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
@@ -134,8 +137,6 @@ fi
# Start backup # Start backup
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Run in a loop to handle the "No space left on device" logic
while [ "1" ]; do
LOG_FILE="$PROFILE_FOLDER/$(date +"%Y-%m-%d-%H%M%S").log" LOG_FILE="$PROFILE_FOLDER/$(date +"%Y-%m-%d-%H%M%S").log"
fn_log_info "Starting backup..." fn_log_info "Starting backup..."
@@ -151,7 +152,6 @@ while [ "1" ]; do
CMD="$CMD --delete-excluded" CMD="$CMD --delete-excluded"
CMD="$CMD --one-file-system" CMD="$CMD --one-file-system"
CMD="$CMD --archive" CMD="$CMD --archive"
CMD="$CMD --progress"
CMD="$CMD --itemize-changes" CMD="$CMD --itemize-changes"
CMD="$CMD --verbose" CMD="$CMD --verbose"
CMD="$CMD --log-file '$LOG_FILE'" CMD="$CMD --log-file '$LOG_FILE'"
@@ -198,8 +198,6 @@ while [ "1" ]; do
exit 1 exit 1
fi fi
# TODO: handle case where only two backup folders are left. In which case, need to remove --link-dest option
OLDEST_BACKUP=$(ls -1 $DEST_FOLDER | grep "$BACKUP_FOLDER_PATTERN" | head -n 1) OLDEST_BACKUP=$(ls -1 $DEST_FOLDER | grep "$BACKUP_FOLDER_PATTERN" | head -n 1)
if [ "$OLDEST_BACKUP" == "" ]; then if [ "$OLDEST_BACKUP" == "" ]; then
fn_log_error "No space left on device, and cannot get path to oldest backup to delete." fn_log_error "No space left on device, and cannot get path to oldest backup to delete."