gastownhall/beads · error
sync to backup: %w
Error message
sync to backup: %w
What it means
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.
Source
Thrown at internal/storage/dolt/store.go:1320
return err
}
backupName := "backup_export"
syncDB, err := s.oneShotConn(0)
if err != nil {
return err
}
defer syncDB.Close()
// Register as a backup remote (idempotent — remove first if exists).
_ = versioncontrolops.BackupRemove(ctx, s.db, backupName)
if err := versioncontrolops.BackupAdd(ctx, s.db, backupName, backupURL); err != nil {
// Another backup (e.g. "default" registered by `bd backup init`) may
// already point to this URL. In that case, sync using the existing
// remote name rather than failing.
if conflict := versioncontrolops.ExtractAddressConflictName(err); conflict != "" {
if syncErr := versioncontrolops.BackupSync(ctx, syncDB, conflict); syncErr != nil {
return fmt.Errorf("sync to backup: %w", syncErr)
}
return nil
}
return fmt.Errorf("register backup remote: %w", err)
}
if err := versioncontrolops.BackupSync(ctx, syncDB, backupName); err != nil {
return fmt.Errorf("sync to backup: %w", err)
}
return nil
}
// RestoreDatabase restores the database from a Dolt backup at dir.
// When force is true, an existing database is overwritten.
func (s *DoltStore) RestoreDatabase(ctx context.Context, dir string, force bool) error {
info, err := os.Stat(dir)
if err != nil {
return fmt.Errorf("backup source does not exist: %w", err)
}View on GitHub (pinned to 71377f2769)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the conflicting existing remote actually points at the same dir
rows, err := db.Query("CALL DOLT_BACKUP('-v')")
// compare each remote's URL against your intended file:// URL before syncing Try / catch
if err := store.BackupDatabase(ctx, dir); err != nil {
if strings.Contains(err.Error(), "sync to backup") {
// stale/corrupt destination: wipe and start clean
os.RemoveAll(dir)
os.MkdirAll(dir, 0o755)
err = store.BackupDatabase(ctx, dir)
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: `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.
Related errors
- register backup remote: %w
- sync to backup: %w
- register backup remote: %w
- sync backup %s: %w
- database not available: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/68685fdbee350047.
Report an issue: GitHub.