diff --git a/internal/backend/backup/jobrun.go b/internal/backend/backup/jobrun.go index ea66070..86f209b 100644 --- a/internal/backend/backup/jobrun.go +++ b/internal/backend/backup/jobrun.go @@ -280,11 +280,6 @@ func RunBackup(job *store.Job, storeInstance *store.Store) (*store.Task, error) defer stdout.Close() defer stderr.Close() - // Start the backup process first - if err := cmd.Start(); err != nil { - return nil, fmt.Errorf("RunBackup: proxmox-backup-client start error (%s): %w", cmd.String(), err) - } - // Create task monitoring channel with buffer to prevent goroutine leak taskChan := make(chan store.Task, 1) @@ -301,6 +296,11 @@ func RunBackup(job *store.Job, storeInstance *store.Store) (*store.Task, error) task, monitorErr = monitorTask(monitorCtx, storeInstance, job, taskChan) }() + // Start the backup process first + if err := cmd.Start(); err != nil { + return nil, fmt.Errorf("RunBackup: proxmox-backup-client start error (%s): %w", cmd.String(), err) + } + // Wait for either monitoring to complete or timeout select { case <-monitorDone: