gastownhall/beads · warning
remove backup %s: %w
Error message
remove backup %s: %w
What it means
BackupRemove runs `CALL DOLT_BACKUP('rm', ?)` to unregister a backup destination, wrapping failures as "remove backup <name>: <cause>". It throws when the ExecContext fails, most commonly because the named backup is not registered. The cause holds the driver-level message.
Source
Thrown at internal/storage/versioncontrolops/backup.go:29
func BackupAdd(ctx context.Context, db DBConn, name, url string) error {
if _, err := db.ExecContext(ctx, "CALL DOLT_BACKUP('add', ?, ?)", name, url); err != nil {
return fmt.Errorf("add backup %s: %w", name, err)
}
return nil
}
// BackupSync pushes the database to the named backup destination.
func BackupSync(ctx context.Context, db DBConn, name string) error {
if _, err := db.ExecContext(ctx, "CALL DOLT_BACKUP('sync', ?)", name); err != nil {
return fmt.Errorf("sync backup %s: %w", name, err)
}
return nil
}
// BackupRemove removes a configured Dolt backup destination.
func BackupRemove(ctx context.Context, db DBConn, name string) error {
if _, err := db.ExecContext(ctx, "CALL DOLT_BACKUP('rm', ?)", name); err != nil {
return fmt.Errorf("remove backup %s: %w", name, err)
}
return nil
}
// BackupRestore restores a database from a backup at the given URL into
// the named database. When force is true, an existing database with the
// same name is overwritten. Mirrors the CLI: dolt backup restore [--force] <url> <db_name>
func BackupRestore(ctx context.Context, db DBConn, url, dbName string, force bool) error {
if force {
if _, err := db.ExecContext(ctx, "CALL DOLT_BACKUP('restore', '--force', ?, ?)", url, dbName); err != nil {
return fmt.Errorf("restore from backup %s: %w", url, err)
}
} else {
if _, err := db.ExecContext(ctx, "CALL DOLT_BACKUP('restore', ?, ?)", url, dbName); err != nil {
return fmt.Errorf("restore from backup %s: %w", url, err)
}
}
return nilView on GitHub (pinned to 71377f2769)
Solutions
- Treat 'not found' causes as idempotent success or check existence before removing
- Verify the backup name against the configured list before calling
- Check the wrapped cause to distinguish config error from connection error
- Retry only transient connection failures
Example fix
// before
_ = vcops.BackupRemove(ctx, db, name)
// after
if err := vcops.BackupRemove(ctx, db, name); err != nil {
if !strings.Contains(err.Error(), "not found") {
return fmt.Errorf("remove backup: %w", err)
}
} Defensive patterns
Strategy: try-catch
Try / catch
if err := vcops.BackupRemove(ctx, db, name); err != nil {
if strings.Contains(err.Error(), "not found") { return nil } // idempotent
return err
} Prevention
- Track registered backup names in application config
- Treat remove-as-missing as success for idempotent cleanup
- Deduplicate cleanup logic to avoid double-remove races
When it happens
Trigger: BackupRemove(ctx, db, name) when db.ExecContext fails: name never registered, name already removed, connection error, or Dolt rejecting the procedure call.
Common situations: Cleaning up a backup config that was already deleted; removing a backup registered in another database; running against a server without DOLT_BACKUP support.
Related errors
- add backup %s: %w
- no backup destination configured
- failed to remove backup: %w
- failed to get current commit: %w
- storage backend does not support backup operations
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/35975829c102d10e.
Report an issue: GitHub.