{"record":{"id":"35975829c102d10e","repo":"gastownhall/beads","slug":"remove-backup-s-w","errorCode":null,"errorMessage":"remove backup %s: %w","messagePattern":"remove backup (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/storage/versioncontrolops/backup.go","lineNumber":29,"sourceCode":"func BackupAdd(ctx context.Context, db DBConn, name, url string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('add', ?, ?)\", name, url); err != nil {\n\t\treturn fmt.Errorf(\"add backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupSync pushes the database to the named backup destination.\nfunc BackupSync(ctx context.Context, db DBConn, name string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('sync', ?)\", name); err != nil {\n\t\treturn fmt.Errorf(\"sync backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupRemove removes a configured Dolt backup destination.\nfunc BackupRemove(ctx context.Context, db DBConn, name string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('rm', ?)\", name); err != nil {\n\t\treturn fmt.Errorf(\"remove backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupRestore restores a database from a backup at the given URL into\n// the named database. When force is true, an existing database with the\n// same name is overwritten. Mirrors the CLI: dolt backup restore [--force] <url> <db_name>\nfunc BackupRestore(ctx context.Context, db DBConn, url, dbName string, force bool) error {\n\tif force {\n\t\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('restore', '--force', ?, ?)\", url, dbName); err != nil {\n\t\t\treturn fmt.Errorf(\"restore from backup %s: %w\", url, err)\n\t\t}\n\t} else {\n\t\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('restore', ?, ?)\", url, dbName); err != nil {\n\t\t\treturn fmt.Errorf(\"restore from backup %s: %w\", url, err)\n\t\t}\n\t}\n\treturn nil","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/backup.go#L11-L47","documentation":"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.","triggerScenarios":"BackupRemove(ctx, db, name) when db.ExecContext fails: name never registered, name already removed, connection error, or Dolt rejecting the procedure call.","commonSituations":"Cleaning up a backup config that was already deleted; removing a backup registered in another database; running against a server without DOLT_BACKUP support.","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"],"exampleFix":"// before\n_ = vcops.BackupRemove(ctx, db, name)\n// after\nif err := vcops.BackupRemove(ctx, db, name); err != nil {\n\tif !strings.Contains(err.Error(), \"not found\") {\n\t\treturn fmt.Errorf(\"remove backup: %w\", err)\n\t}\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := vcops.BackupRemove(ctx, db, name); err != nil {\n\tif strings.Contains(err.Error(), \"not found\") { return nil } // idempotent\n\treturn err\n}","preventionTips":["Track registered backup names in application config","Treat remove-as-missing as success for idempotent cleanup","Deduplicate cleanup logic to avoid double-remove races"],"tags":["dolt","backup","sql"],"backgroundTag":"dolt-backup-operation-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}