When your backup script is running for too long it sometimes causes the second backup script starting at the time when previous backup is still running. This increasing pressure on the database, makes server slower, could start chain of backup processes and in some cases may break backup integrity.
Simplest solution is to avoid this undesired situation by adding locking to your backup script and prevent script to start second time when it’s already running.
Here is working sample. You will need to replace “sleep 10″ string with actual backup script call:
#!/bin/bash LOCK_NAME="/tmp/my.lock" if [[ -e $LOCK_NAME ]] ; then echo "re-entry, exiting" exit 1 fi ### Placing lock file touch $LOCK_NAME echo -n "Started..." ### Performing required work sleep 10 ### Removing lock rm -f $LOCK_NAME echo "Done."
It works perfectly most of the times. Problem is that you could still theoretically run two …
[Read more]