Skip to content

Cancelling an Offsite Sync job doesn't stop rclone; the transfer keeps running #577

Closed

Description

@jandro

Description

When you cancel a running Offsite sync job (s3_sync) from the Queue page, the job is marked cancelled, but the rclone sync process inside the container keeps running. It keeps sending data to the destination until it finishes on its own. The only way to stop it is to kill it by hand:

docker compose exec bbs pkill -f rclone

Seen with an "SSH host (SFTP)" destination.

Expected: cancelling stops the rclone transfer, as it already does for agent jobs, where the cancel is passed on to the agent.

Cause (from reading the v2.101.0 source):

  • Cancel only updates the database. QueueController::cancel() (src/Controllers/QueueController.php:409) and AdminApiController::cancelQueueJob() (src/Controllers/Api/AdminApiController.php:4622) only update the backup_jobs row, plus queue a break-lock for borg task types. Nothing signals the process running on the server.
  • The sync loop never checks for a cancel. S3SyncService::runViaHelper() (src/Services/S3SyncService.php:549) starts sudo bbs-ssh-helper rclone-transfer … with proc_open and calls pump() without a timeout. pump() (:462) loops until the process exits and never re-reads the job status.
  • rclone is two sudo layers away from PHP. The helper starts rclone with sudo -u <repo user> env … rclone sync, so rclone is a grandchild of the PHP process and runs as a different user.

Possible fix:

  • Check for the cancel: in pump(), which already wakes every 200 ms, check the job status every few seconds. When it's cancelled, stop the transfer and return.
  • Make sure the kill reaches rclone: terminating $proc alone probably won't, because rclone is behind two sudo layers and runs as another user. Some options:
    • have the helper exec rclone, or trap SIGTERM and pass it on;
    • start the transfer in its own process group and kill the whole group;
    • add a helper subcommand, e.g. bbs-ssh-helper rclone-cancel <user>, that kills that user's rclone.
  • Possible side effect today: while an orphaned rclone is still writing, a new sync of the same repository could start and write to the same destination path.

Steps to Reproduce

  1. Set up Offsite Sync to an SFTP destination for a repository big enough that the sync takes a few minutes.
  2. Start the sync and wait until the queue shows rclone progress.
  3. Cancel the job from the Queue page (or through the API's cancelQueueJob).
  4. Run docker compose exec bbs ps aux | grep rclone. rclone is still running, and the destination keeps receiving data.

Installation Type

Docker

BBS Version

2.101.0

Agent Version (if applicable)

No response

Agent OS (if applicable)

None

Relevant Logs

Activity

  1. added
    bug
    on Nov 16, 2026
  2. added a commit that references this issue on Nov 17, 2026
  3. marcpope commented on Nov 17, 2026

    @marcpope
    Owner

    Thanks @jandro, and for the write-up. The transfer loop now checks the job every two seconds and sends SIGTERM when it has been cancelled, with SIGKILL as a fallback after 15 seconds. bbs-ssh-helper runs rclone in the background and relays the signal through both sudo layers, so rclone gets it. The scheduler logs "stopped: job cancelled" and leaves the row alone. Offsite restores go through the same path.

    Tested on my internal test server with a 7 GB SFTP upload: rclone and the helper were gone two seconds after the cancel. In the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions