{"record":{"id":"de07de785aa30639","repo":"gastownhall/beads","slug":"sync-backup-s-w","errorCode":null,"errorMessage":"sync backup %s: %w","messagePattern":"sync backup (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/backup.go","lineNumber":21,"sourceCode":"import (\n\t\"context\"\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\n// BackupAdd registers a Dolt backup destination.\nfunc BackupAdd(ctx context.Context, db DBConn, name, url string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('add', ?, ?)\", name, url); err != nil {\n\t\treturn fmt.Errorf(\"add backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupSync pushes the database to the named backup destination.\nfunc BackupSync(ctx context.Context, db DBConn, name string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('sync', ?)\", name); err != nil {\n\t\treturn fmt.Errorf(\"sync backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupRemove removes a configured Dolt backup destination.\nfunc BackupRemove(ctx context.Context, db DBConn, name string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('rm', ?)\", name); err != nil {\n\t\treturn fmt.Errorf(\"remove backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupRestore restores a database from a backup at the given URL into\n// the named database. When force is true, an existing database with the\n// same name is overwritten. Mirrors the CLI: dolt backup restore [--force] <url> <db_name>\nfunc BackupRestore(ctx context.Context, db DBConn, url, dbName string, force bool) error {\n\tif force {\n\t\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('restore', '--force', ?, ?)\", url, dbName); err != nil {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/backup.go#L3-L39","documentation":"BackupSync runs `CALL DOLT_BACKUP('sync', ?)` to push the database to a previously registered backup destination, wrapping failures as \"sync backup <name>: <cause>\". It throws when the push to the backup remote fails or the named backup does not exist. The wrapped driver error carries the underlying reason.","triggerScenarios":"BackupSync(ctx, db, name) when db.ExecContext fails: backup name not registered (no prior BackupAdd), destination unreachable or read-only, or the sync write errors mid-transfer.","commonSituations":"Syncing a backup registered in a different Dolt directory/DB; destination filesystem full or permissions denied; network outage to a remote backup; typo in the backup name.","solutions":["Verify the name was registered first via BackupAdd (or `dolt backup add`)","Check the wrapped cause for unreachable/read-only destination and fix storage or network","List configured backups (SELECT from dolt_backup or `dolt backup -v`) to confirm the name","Retry transient network failures with backoff"],"exampleFix":"// before\nif err := vcops.BackupSync(ctx, db, \"offsite\"); err != nil { panic(err) }\n// after\nif err := vcops.BackupAdd(ctx, db, \"offsite\", backupURL); err != nil { return err }\nif err := vcops.BackupSync(ctx, db, \"offsite\"); err != nil {\n\treturn fmt.Errorf(\"push to offsite backup: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// ensure backup exists first\nif err := vcops.BackupAdd(ctx, db, name, url); err != nil { return err }\n// then safe to sync","typeGuard":null,"tryCatchPattern":"if err := vcops.BackupSync(ctx, db, name); err != nil {\n\tif isTransient(errors.Unwrap(err)) {\n\t\treturn retryWithBackoff(3, func() error { return vcops.BackupSync(ctx, db, name) })\n\t}\n\treturn err\n}","preventionTips":["Register the backup (BackupAdd) before the first sync","Monitor destination disk space and permissions","Retry network-caused syncs with exponential backoff"],"tags":["dolt","backup","sync","network"],"backgroundTag":"dolt-backup-operation-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}