{"record":{"id":"eed561a2d7d68671","repo":"gastownhall/beads","slug":"backup-source-is-not-a-directory-s-eed561","errorCode":null,"errorMessage":"backup source is not a directory: %s","messagePattern":"backup source is not a directory: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/version_control.go","lineNumber":777,"sourceCode":"\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":759,"sourceCodeEnd":789,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/version_control.go#L759-L789","documentation":"Returned by RestoreDatabase when the source path exists but is not a directory. A Dolt backup source must be a directory containing backup data, so a file at that path is rejected with this plain message.","triggerScenarios":"Calling RestoreDatabase(ctx, dir, force) where os.Stat succeeds but IsDir() is false — pointing restore at a zip/tar archive, a database file, or a symlink to a file instead of the extracted backup directory.","commonSituations":"Trying to restore directly from a compressed archive without extracting it; passing the beads .bdb file instead of the backup dir; restoring a path exported as a single file by another tool.","solutions":["Extract any archive into a directory first, then restore from that directory","Point restore at the backup directory, not a file inside or a sibling file","Verify with `ls -la <path>` that it is a directory containing Dolt backup data","If a file occupies the expected path, choose a different directory path"],"exampleFix":"// before\nstore.RestoreDatabase(ctx, \"/backups/beads.tar.gz\", false)\n// after\nexec.Command(\"tar\", \"-xzf\", \"/backups/beads.tar.gz\", \"-C\", \"/tmp/restore\")\nstore.RestoreDatabase(ctx, \"/tmp/restore/beads\", false)","handlingStrategy":"validation","validationCode":"info, err := os.Stat(dir)\nif err != nil || !info.IsDir() {\n    return fmt.Errorf(\"restore source must be an extracted backup directory: %%s\", dir)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Extract archives into a directory before restoring","Never point restore at compressed files or db files","Validate the directory contains Dolt backup data (dolt backup inspect or ls)"],"tags":["go","dolt","restore","filesystem"],"backgroundTag":"path-not-a-directory","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}