{"record":{"id":"162934bc549c763a","repo":"gastownhall/beads","slug":"backup-source-does-not-exist-w-162934","errorCode":null,"errorMessage":"backup source does not exist: %w","messagePattern":"backup source does not exist: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/version_control.go","lineNumber":774,"sourceCode":"\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"register backup remote: %w\", err)\n\t\t}\n\t\tif err := versioncontrolops.BackupSync(ctx, db, backupName); err != nil {\n\t\t\treturn fmt.Errorf(\"sync to backup: %w\", err)\n\t\t}\n\t\treturn nil\n\t})\n}\n\n// RestoreDatabase restores the database from a Dolt backup at dir.\n// The dir must exist locally and contain a valid Dolt backup.\n// When force is true, an existing database is overwritten.\nfunc (s *EmbeddedDoltStore) RestoreDatabase(ctx context.Context, dir string, force bool) error {\n\tinfo, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"backup source does not exist: %w\", err)\n\t}\n\tif !info.IsDir() {\n\t\treturn fmt.Errorf(\"backup source 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\n\treturn s.withMutatingDBConn(ctx, func(db versioncontrolops.DBConn) error {\n\t\treturn versioncontrolops.BackupRestore(ctx, db, backupURL, s.database, force)\n\t})\n}\n","sourceCodeStart":756,"sourceCodeEnd":789,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/version_control.go#L756-L789","documentation":"Returned by RestoreDatabase when the source backup directory cannot be stat-ed, i.e. it does not exist or is inaccessible. Restore requires a valid local Dolt backup directory, so it fails fast with the os.Stat error wrapped.","triggerScenarios":"Calling RestoreDatabase(ctx, dir, force) with a dir that was deleted, moved, never created, is on an unmounted volume, or has permission problems.","commonSituations":"Restoring on a new machine where the backup volume isn't mounted; typo'd restore path; backup directory cleaned up by a retention job before the restore attempt.","solutions":["Verify the backup directory path exists: ls <dir>","Mount the volume/drive containing the backup before restoring","Fix path typos and use absolute paths","Recreate the backup from a healthy replica if the source is gone"],"exampleFix":"// before\nstore.RestoreDatabase(ctx, \"/mnt/backup/beads\", true)\n// after\nif _, err := os.Stat(\"/mnt/backup/beads\"); err != nil {\n    return fmt.Errorf(\"mount/locate backup first: %%w\", err)\n}\nstore.RestoreDatabase(ctx, \"/mnt/backup/beads\", true)","handlingStrategy":"validation","validationCode":"info, err := os.Stat(dir)\nif err != nil {\n    return fmt.Errorf(\"backup source %%s unavailable: %%w\", dir, err)\n}\nif !info.IsDir() { return fmt.Errorf(\"%%s is not a directory\", dir) }","typeGuard":null,"tryCatchPattern":"if err := store.RestoreDatabase(ctx, dir, false); err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && os.IsNotExist(pe) { /* mount/locate backup before retry */ }\n}","preventionTips":["Verify backup path exists before restore operations","Mount backup volumes before running restore jobs","Use absolute, documented backup paths"],"tags":["go","dolt","restore","filesystem"],"backgroundTag":"path-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}