{"record":{"id":"a78b83e685c49661","repo":"gastownhall/beads","slug":"backup-destination-does-not-exist-w","errorCode":null,"errorMessage":"backup destination does not exist: %w","messagePattern":"backup destination does not exist: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":1294,"sourceCode":"\tdb, err := s.oneShotConn(0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer db.Close()\n\treturn versioncontrolops.BackupSync(ctx, db, name)\n}\n\n// BackupRemove removes a configured Dolt backup destination.\nfunc (s *DoltStore) BackupRemove(ctx context.Context, name string) error {\n\treturn versioncontrolops.BackupRemove(ctx, s.db, name)\n}\n\n// BackupDatabase registers dir as a file:// Dolt backup remote and syncs\n// the full database to it, preserving complete commit history.\nfunc (s *DoltStore) BackupDatabase(ctx context.Context, dir string) error {\n\tinfo, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"backup destination does not exist: %w\", err)\n\t}\n\tif !info.IsDir() {\n\t\treturn fmt.Errorf(\"backup destination is not a directory: %s\", dir)\n\t}\n\n\tbackupURL, err := versioncontrolops.DirToFileURL(dir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbackupName := \"backup_export\"\n\n\tsyncDB, err := s.oneShotConn(0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer syncDB.Close()\n\n\t// Register as a backup remote (idempotent — remove first if exists).","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L1276-L1312","documentation":"BackupDatabase was asked to back the Dolt database up into `dir`, but os.Stat(dir) failed, meaning the destination path does not exist (or is otherwise inaccessible). The error wraps the underlying os.Stat error (e.g. 'no such file or directory', 'permission denied'). The backup is aborted before any remote registration or sync happens.","triggerScenarios":"Calling DoltStore.BackupDatabase(ctx, dir) with a directory path that has not been created yet, a typo'd path, or a path the process cannot stat due to permissions — before BackupAdd/BackupSync ever run.","commonSituations":"Using `bd backup init`/`bd backup` with a relative path from the wrong working directory; pointing at a path on an unmounted volume; automation that assumes the tool creates the destination (it does not); running as a user lacking access to the path.","solutions":["Create the destination directory first: mkdir -p <dir> (BackupDatabase requires an existing directory, it will not create one).","Check the wrapped os.Stat error: 'no such file or directory' means create it; 'permission denied' means fix ownership/permissions or run as the right user.","Verify you are passing an absolute path or running from the intended working directory if using a relative path.","Confirm the volume/mount holding the destination is actually mounted."],"exampleFix":"// before\nerr := store.BackupDatabase(ctx, \"/backups/beads\") // dir missing\n// after\nif err := os.MkdirAll(\"/backups/beads\", 0o755); err != nil {\n    return err\n}\nerr := store.BackupDatabase(ctx, \"/backups/beads\")","handlingStrategy":"validation","validationCode":"info, err := os.Stat(dir)\nif err != nil {\n    if os.IsNotExist(err) {\n        if err := os.MkdirAll(dir, 0o755); err != nil { return err }\n    } else {\n        return err\n    }\n}","typeGuard":"func isExistingDir(path string) bool {\n    info, err := os.Stat(path)\n    return err == nil && info.IsDir()\n}","tryCatchPattern":"if err := store.BackupDatabase(ctx, dir); err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && os.IsNotExist(pe) {\n        os.MkdirAll(dir, 0o755)\n        err = store.BackupDatabase(ctx, dir)\n    }\n}","preventionTips":["Always create the backup directory (mkdir -p) before invoking BackupDatabase — it does not create it for you.","Use absolute paths in scripts to avoid working-directory surprises.","Pre-flight check with os.Stat in automation before calling backup commands."],"tags":["backup","filesystem","dolt","validation"],"backgroundTag":"directory-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}