Prevent overlapping backup executions #105

Open
opened 2026-11-29 06:06:43 +00:00 by ChasquiLabo · 0 comments

During a recent incident in our production Co-op Cloud infrastructure, we found three concurrent Backup Bot Two processes running against the same Restic repository, each started by the daily cron schedule.

Due to a network performance issue, the initial backup took longer than 24 hours, but subsequent scheduled backups were started while the previous ones were still running.

This resulted in increased CPU, memory, disk and network usage.

Current behaviour

Neither cronjob.sh nor the create() function in backupbot.py appears to implement a mechanism to prevent overlapping backups.

Concurrent executions may also interfere with shared resources, such as database dumps, the /secrets/ directory and /tmp/backup.log.

Proposed solution

  • Implement a non-blocking file lock using Python's fcntl.flock.
  • Acquire the lock before running backup preparation and pre-backup hooks.
  • Hold the lock until the backup and post-backup hooks have finished.
  • Skip new backup executions when another backup is already running, with an appropriate log message.
  • Enable swarm.cronjob.skip-running=true in the optional swarm-cronjob configuration.

This would protect both scheduled and manually triggered backups without changing Restic's concurrent repository access behaviour.

Environment

  • Backup Bot Two: 2.4.0
  • Restic: 0.18.1
  • Ubuntu Server 24.04 LTS
  • Docker Swarm
  • S3-compatible storage (Storj)

We would be happy to contribute a patch and test it on our infrastructure.
Issue made using LLM Chatgpt

During a recent incident in our production Co-op Cloud infrastructure, we found three concurrent Backup Bot Two processes running against the same Restic repository, each started by the daily cron schedule. Due to a network performance issue, the initial backup took longer than 24 hours, but subsequent scheduled backups were started while the previous ones were still running. This resulted in increased CPU, memory, disk and network usage. ### Current behaviour Neither `cronjob.sh` nor the `create()` function in `backupbot.py` appears to implement a mechanism to prevent overlapping backups. Concurrent executions may also interfere with shared resources, such as database dumps, the `/secrets/` directory and `/tmp/backup.log`. ### Proposed solution - Implement a non-blocking file lock using Python's `fcntl.flock`. - Acquire the lock before running backup preparation and pre-backup hooks. - Hold the lock until the backup and post-backup hooks have finished. - Skip new backup executions when another backup is already running, with an appropriate log message. - Enable `swarm.cronjob.skip-running=true` in the optional swarm-cronjob configuration. This would protect both scheduled and manually triggered backups without changing Restic's concurrent repository access behaviour. ### Environment - Backup Bot Two: 2.4.0 - Restic: 0.18.1 - Ubuntu Server 24.04 LTS - Docker Swarm - S3-compatible storage (Storj) We would be happy to contribute a patch and test it on our infrastructure. Issue made using LLM Chatgpt
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coop-cloud/backup-bot-two#105