gastownhall/beads · error

failed to remove backup: %w

Error message

failed to remove backup: %w

What it means

When bs.BackupRemove fails with an error that is not a benign 'not found' (i.e. does not contain 'not found' or 'no backup'), the command wraps it as 'failed to remove backup: %w' preserving the underlying cause. This indicates a real failure talking to the Dolt backup subsystem — bad URL, network issue to the remote, permissions, or driver error.

Source

Thrown at cmd/bd/backup_dolt.go:434

				c.CloseEventAndAdd(evt)
			}
		}()

		ctx := rootCtx
		if store == nil {
			return fmt.Errorf("no store available")
		}

		bs, ok := storage.UnwrapStore(store).(storage.BackupStore)
		if !ok {
			return fmt.Errorf("storage backend does not support backup operations")
		}

		if err := bs.BackupRemove(ctx, defaultDoltBackupName); err != nil {
			if strings.Contains(err.Error(), "not found") || strings.Contains(err.Error(), "no backup") {
				return fmt.Errorf("no backup destination configured")
			}
			return fmt.Errorf("failed to remove backup: %w", err)
		}

		// Also remove backup_export if it exists (auto-export may have created it at same URL)
		_ = bs.BackupRemove(ctx, "backup_export")

		// Remove local config
		if path, err := doltBackupConfigPath(); err == nil {
			_ = os.Remove(path)
		}
		if path, err := doltBackupStatePath(); err == nil {
			_ = os.Remove(path)
		}

		if jsonOutput {
			return outputJSON(map[string]interface{}{"removed": true})
		}

		fmt.Println("Backup destination removed.")

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause after '%w' to identify the root error (network vs permissions vs state)
  2. Verify the backup remote URL is reachable (curl / dolt backup list) and credentials are valid
  3. If the remote is permanently gone, manually delete the local dolt-backup.json config and any local backup registration
  4. Retry after network is restored

Example fix

// before
bd backup remove
// error: failed to remove backup: dial tcp: connection refused
// after: point at a live remote or clean local state
dolt backup remove <name>  # or fix URL, then
bd backup remove
Defensive patterns

Strategy: retry

Validate before calling

// pre-check remote reachability
if !isBackupRemoteReachable(backupURL) {
    return errors.New("backup remote unreachable; fix URL/credentials before removing")
}

Try / catch

err := bs.BackupRemove(ctx, defaultDoltBackupName)
if err != nil && !isNotFound(err) {
    var netErr net.Error
    if errors.As(err, &netErr) {
        // retry with backoff or report network problem
    }
    return fmt.Errorf("failed to remove backup: %w", err)
}

Prevention

When it happens

Trigger: Running `bd backup remove` when the underlying Dolt BackupRemove call errors for reasons other than absence: unreachable backup remote URL, authentication failure, corrupt local Dolt state, or filesystem errors.

Common situations: Backup remote was decommissioned or URL changed (connection refused/timeouts), credentials rotated, network offline, or the local .dolt directory is corrupted.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/7f345a38a8be73d3. Report an issue: GitHub.