rsync-time-backup icon indicating copy to clipboard operation
rsync-time-backup copied to clipboard

built-in lock does not work for linux

Open kapitainsky opened this issue 5 years ago • 0 comments

Original check whether previous backup to the same destination is still running does not work for linux. It is at the moment:

		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
               fi

If backup is run to local disk rsync spawns two processes and $INPROGRESS_FILE contains PID of newer rsync instance than one returned by pgrep -o -f

Also some edge cases are not caught e.g. if there is another older rsync_tmbackup backup already running (to different destination) pgrep will pick up its PID instead of one of our backup we try to lock.

I suggest to change it and use:

                RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
                if ps -p "$RUNNINGPID" -o command | grep "$APPNAME"
                then
                        fn_log_error "Previous backup task is still active - aborting."
                        exit 1
                fi

It is better explicitly check if process with PID from $INPROGRESS_FILE is running and it is another $APPNAME process.

I will create pull request with suggested change.

kapitainsky avatar Apr 01 '19 14:04 kapitainsky