{"record":{"id":"cd53ac5a61fb0240","repo":"gastownhall/beads","slug":"storage-backend-does-not-support-backup-operations-cd53ac","errorCode":null,"errorMessage":"storage backend does not support backup operations","messagePattern":"storage backend does not support backup operations","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/backup_restore.go","lineNumber":89,"sourceCode":"\n\t\treturn nil\n\t},\n}\n\nfunc init() {\n\tbackupRestoreCmd.Flags().Bool(\"force\", false, \"Overwrite existing database with backup contents\")\n\tbackupCmd.AddCommand(backupRestoreCmd)\n}\n\n// runBackupRestore restores the database from a Dolt-native backup.\nfunc runBackupRestore(ctx context.Context, s storage.DoltStorage, dir string, force bool) error {\n\tif s == nil {\n\t\treturn fmt.Errorf(\"database is not initialized. Run 'bd init' first\")\n\t}\n\n\tbs, ok := storage.UnwrapStore(s).(storage.BackupStore)\n\tif !ok {\n\t\treturn fmt.Errorf(\"storage backend does not support backup operations\")\n\t}\n\n\tif err := bs.RestoreDatabase(ctx, dir, force); err != nil {\n\t\treturn err\n\t}\n\n\t// After a force restore, the database's _project_id may differ from\n\t// metadata.json (the backup came from a different project). Sync\n\t// metadata.json to match the restored database so the identity check\n\t// doesn't reject subsequent connections.\n\tif force {\n\t\tif err := syncProjectIDFromDB(ctx, s); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to sync project ID after restore: %v\\n\", err)\n\t\t}\n\t}\n\n\t// Register the restore source as the backup destination so\n\t// `bd backup sync` works immediately without a separate `bd backup add`.","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/backup_restore.go#L71-L107","documentation":"After obtaining the storage handle, runBackupRestore unwraps it with storage.UnwrapStore and asserts it implements storage.BackupStore. Backends that do not implement RestoreDatabase/backup operations fail this type assertion and produce this error. Restore is only supported by Dolt-native storage.","triggerScenarios":"'bd backup restore' is invoked with a storage backend whose concrete type does not implement storage.BackupStore — e.g. a non-Dolt driver, a remote/proxied handle that doesn't expose backup ops, or a mock in tests.","commonSituations":"Using an alternative storage driver or server mode where the handle is proxied and lacks BackupStore; version mismatch where an older backend predates the BackupStore interface; unit tests injecting a plain DoltStorage without backup support.","solutions":["Use the default Dolt storage backend for backup/restore operations","If running against the server/proxied mode, perform restore with a direct (local) database handle","Upgrade beads so the storage driver in use implements the BackupStore interface","Check which backend is active (env/config) and switch back to Dolt"],"exampleFix":"// before\nbs, ok := storage.UnwrapStore(s).(storage.BackupStore)\nif !ok { ... } // fails on non-Dolt backend\n// after\n// run against a local Dolt-backed store, e.g. unset server mode:\n// BD_SERVER= bd backup restore /path/to/backup","handlingStrategy":"type-guard","validationCode":"if _, ok := storage.UnwrapStore(s).(storage.BackupStore); !ok {\n\treturn fmt.Errorf(\"current backend (%T) does not support backup restore; use Dolt storage\", s)\n}","typeGuard":"bs, ok := storage.UnwrapStore(s).(storage.BackupStore)\nif !ok { /* fall back or error */ }","tryCatchPattern":"bs, ok := storage.UnwrapStore(s).(storage.BackupStore)\nif !ok {\n\treturn fmt.Errorf(\"backend %T lacks BackupStore; rerun without server/proxy mode\", s)\n}","preventionTips":["Check for server/proxy mode (usesProxiedServer) before attempting backup/restore and use a direct Dolt handle","Pin beads versions so the driver in use implements BackupStore","Feature-detect with a type assertion rather than assuming backup support","Document which storage backends support backup operations"],"tags":["storage","backup","interface","go"],"backgroundTag":"backend-unsupported-operation","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}