Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #116 allow backup directory with spaces #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions rsync_tmbackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn_parse_date() {
}

fn_find_backups() {
fn_run_cmd "find "$DEST_FOLDER/" -maxdepth 1 -type d -name \"????-??-??-??????\" -prune | sort -r"
fn_run_cmd "find "\'$DEST_FOLDER/\'" -maxdepth 1 -type d -name \"????-??-??-??????\" -prune | sort -r"
}

fn_expire_backup() {
Expand Down Expand Up @@ -289,10 +289,10 @@ fi
# Handle case where a previous backup failed or was interrupted.
# -----------------------------------------------------------------------------

if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then
if [ -n "$(fn_find "\"$INPROGRESS_FILE\"")" ]; then
if [ "$OSTYPE" == "cygwin" ]; then
# 1. Grab the PID of previous run from the PID file
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
RUNNINGPID="$(fn_run_cmd "cat \"$INPROGRESS_FILE\"")"

# 2. Get the command for the process currently running under that PID and look for our script name
RUNNINGCMD="$(procps -wwfo cmd -p $RUNNINGPID --no-headers | grep "$APPNAME")"
Expand All @@ -306,7 +306,7 @@ if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then
exit 1
fi
else
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
RUNNINGPID="$(fn_run_cmd "cat \"$INPROGRESS_FILE\"")"
if [ "$RUNNINGPID" = "$(pgrep -o -f "$APPNAME")" ]; then
fn_log_error "Previous backup task is still active - aborting."
exit 1
Expand All @@ -324,7 +324,7 @@ if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then
PREVIOUS_DEST=""
fi
# update PID to current process to avoid multiple concurrent resumes
fn_run_cmd "echo $MYPID > $INPROGRESS_FILE"
fn_run_cmd "echo $MYPID > \"$INPROGRESS_FILE\""
fi
fi

Expand Down Expand Up @@ -410,7 +410,7 @@ while : ; do
fn_log_info "Running command:"
fn_log_info "$CMD"

fn_run_cmd "echo $MYPID > $INPROGRESS_FILE"
fn_run_cmd "echo $MYPID > \"$INPROGRESS_FILE\""
eval $CMD

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -457,7 +457,7 @@ while : ; do
fn_rm_file "$DEST_FOLDER/latest"
fn_ln "$(basename -- "$DEST")" "$DEST_FOLDER/latest"

fn_rm_file "$INPROGRESS_FILE"
fn_rm_file "\"$INPROGRESS_FILE\""

exit $EXIT_CODE
done