prevent backup from running in parallel

There are different ways of doing this, but IMO the easiest is inserting flock before the command in the crontab file:

5  *  *  *  *   root  flock -n /var/lock/backup /usr/local/bin/backup

The /var/lock/backup file is the lock that flock uses and -n immediately makes the command fail if the lock already exists.

This could of course mean that if one backup takes 1 hour and 1 minute, that the next one starts 59 minutes later. If that is a problem you could look into using -x.

Tags:

Backup

Rsync