{"record":{"id":"68685fdbee350047","repo":"gastownhall/beads","slug":"sync-to-backup-w","errorCode":null,"errorMessage":"sync to backup: %w","messagePattern":"sync to backup: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":1320,"sourceCode":"\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).\n\t_ = versioncontrolops.BackupRemove(ctx, s.db, backupName)\n\tif err := versioncontrolops.BackupAdd(ctx, s.db, backupName, backupURL); err != nil {\n\t\t// Another backup (e.g. \"default\" registered by `bd backup init`) may\n\t\t// already point to this URL. In that case, sync using the existing\n\t\t// remote name rather than failing.\n\t\tif conflict := versioncontrolops.ExtractAddressConflictName(err); conflict != \"\" {\n\t\t\tif syncErr := versioncontrolops.BackupSync(ctx, syncDB, conflict); syncErr != nil {\n\t\t\t\treturn fmt.Errorf(\"sync to backup: %w\", syncErr)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"register backup remote: %w\", err)\n\t}\n\tif err := versioncontrolops.BackupSync(ctx, syncDB, backupName); err != nil {\n\t\treturn fmt.Errorf(\"sync to backup: %w\", err)\n\t}\n\treturn nil\n}\n\n// RestoreDatabase restores the database from a Dolt backup at dir.\n// When force is true, an existing database is overwritten.\nfunc (s *DoltStore) 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}","sourceCodeStart":1302,"sourceCodeEnd":1338,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L1302-L1338","documentation":"BackupAdd reported an address conflict (another backup remote already points at the same file:// URL) and the code recovered by syncing via the existing remote's name via BackupSync(ctx, syncDB, conflict) — but that sync itself failed. This means the pre-existing backup remote (e.g. \"default\" registered by `bd backup init`) could not be synced to the destination.","triggerScenarios":"BackupAdd returned an address-conflict error, ExtractAddressConflictName yielded a remote name, and BackupSync on that remote failed — e.g. the existing remote's URL differs from the target, the destination directory is corrupt/not a Dolt backup, or the connection dropped mid-sync.","commonSituations":"`bd backup init` previously registered a remote with the same URL pointing at a stale or wiped directory; the destination contains a partial/failed backup that Dolt refuses to update; disk full during the sync; server connection error on syncDB.","solutions":["Inspect the wrapped BackupSync error: for corrupt/partial destination state, delete the destination directory contents and re-run the backup.","Verify the existing conflicting remote's URL matches your intended destination (`dolt backup` / backup list); if it points elsewhere, remove or rename it and retry.","Check available disk space at the destination — a full disk aborts the sync partway.","Retry after resolving transient connection issues; syncDB operations go over SQL and inherit connection-class failures."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure the conflicting existing remote actually points at the same dir\nrows, err := db.Query(\"CALL DOLT_BACKUP('-v')\")\n// compare each remote's URL against your intended file:// URL before syncing","typeGuard":null,"tryCatchPattern":"if err := store.BackupDatabase(ctx, dir); err != nil {\n    if strings.Contains(err.Error(), \"sync to backup\") {\n        // stale/corrupt destination: wipe and start clean\n        os.RemoveAll(dir)\n        os.MkdirAll(dir, 0o755)\n        err = store.BackupDatabase(ctx, dir)\n    }\n}","preventionTips":["Keep one canonical backup remote name per destination URL to minimize conflict-recovery syncs.","After failed backups, wipe partial destination state before retrying.","Monitor free disk space at backup destinations — full disks are the top sync killer.","Register the backup with `bd backup init` before running repeated backups so the conflict path is exercised and known-good."],"tags":["dolt","backup","sync","remote"],"backgroundTag":"backup-sync-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}