{"record":{"id":"d9f889b2c3cd65c8","repo":"gastownhall/beads","slug":"sync-to-backup-w-d9f889","errorCode":null,"errorMessage":"sync to backup: %w","messagePattern":"sync to backup: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/version_control.go","lineNumber":755,"sourceCode":"\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\treturn s.withMutatingDBConn(ctx, func(db versioncontrolops.DBConn) error {\n\t\t// Register as a backup remote (idempotent — remove first if exists).\n\t\t_ = versioncontrolops.BackupRemove(ctx, db, backupName)\n\t\tif err := versioncontrolops.BackupAdd(ctx, db, backupName, backupURL); err != nil {\n\t\t\t// Another backup (e.g. \"default\" registered by `bd backup init`) may\n\t\t\t// already point to this URL. In that case, sync using the existing\n\t\t\t// remote name rather than failing.\n\t\t\tif conflict := versioncontrolops.ExtractAddressConflictName(err); conflict != \"\" {\n\t\t\t\tif syncErr := versioncontrolops.BackupSync(ctx, db, conflict); syncErr != nil {\n\t\t\t\t\treturn fmt.Errorf(\"sync to backup: %w\", syncErr)\n\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 {","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/version_control.go#L737-L773","documentation":"Returned when BackupDatabase falls back to syncing via an existing backup remote that already points at the same URL (address-conflict path), and that BackupSync fails. The remote registration was skipped because another remote (e.g. \"default\" from `bd backup init`) owns the URL, but replicating data to it errored.","triggerScenarios":"BackupAdd returns an address conflict; ExtractAddressConflictName yields the existing remote name; BackupSync(ctx, db, conflict) then fails — permission denied writing to the backup dir, disk full, or Dolt backup engine error.","commonSituations":"Re-running backup against a dir already registered by `bd backup init`; backup drive full or read-only; corrupted existing backup directory refusing new writes.","solutions":["Check disk space and writability of the backup directory","Inspect the wrapped syncErr root cause in the error chain","Remove and re-register the conflicting backup remote if it points at a stale location","Retry the backup after resolving filesystem issues"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check backup dir is writable before syncing\nprobe := filepath.Join(dir, \".write-probe\")\nif err := os.WriteFile(probe, []byte(\"x\"), 0o600); err != nil {\n    return fmt.Errorf(\"backup dir not writable: %%w\", err)\n}\nos.Remove(probe)","typeGuard":null,"tryCatchPattern":"if err := store.BackupDatabase(ctx, dir); err != nil {\n    if strings.Contains(err.Error(), \"sync to backup\") { /* filesystem-level issue: check space/permissions */ }\n}","preventionTips":["Monitor disk space on backup volumes","Deduplicate remote names pointing at the same URL","Verify backup dir integrity periodically"],"tags":["go","dolt","backup","sync"],"backgroundTag":"backup-sync-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}