laurent22 / rsync-time-backup

Time Machine style backup with rsync.
3.41k stars 449 forks source link

bugfix - built in lock - linux #163

Closed kapitainsky closed 5 years ago

kapitainsky commented 5 years ago

Existing lock does not work as pgrep can return multiple pid (if other backups are running) and in this case condition to abort won't be met. It will also happen when backup is run locally (e.g. to another filesystem) as in this case rsync spawns two processes.

laurent22 commented 5 years ago

My Bash is a bit rusty. Could you explain the difference between the previous code and the new one?

kapitainsky commented 5 years ago

Your code asks the system for all pids of processes with name like the script. Then you compare it to single pid from inprogress file. Which means that if there is more than one backup running your lock never works as condition is never met - you compare single number to the list of numbers.

I changed it to ask the system to provide the name of the specific process (with pid from inprogress file). Then I check if it is the script name.

laurent22 commented 5 years ago

That makes sense, thanks for clarifying.