{"record":{"id":"76de930f0733abaf","repo":"benbjohnson/litestream","slug":"sync-replica-for-s-w","errorCode":null,"errorMessage":"sync replica for %s: %w","messagePattern":"sync replica for (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/replicate.go","lineNumber":409,"sourceCode":"\n// runOnce performs one-shot replication for all databases.\n// It syncs all databases, optionally takes snapshots, and enforces retention.\nfunc (c *ReplicateCommand) runOnce(ctx context.Context) {\n\tvar err error\n\tdefer func() { c.execCh <- err }()\n\n\tfor _, db := range c.Store.DBs() {\n\t\tslog.Info(\"syncing database\", \"path\", db.Path())\n\n\t\t// Sync the database to process any pending WAL changes.\n\t\tif err = db.Sync(ctx); err != nil {\n\t\t\terr = fmt.Errorf(\"sync database %s: %w\", db.Path(), err)\n\t\t\treturn\n\t\t}\n\n\t\t// Sync the replica to upload any pending LTX files.\n\t\tif err = db.Replica.Sync(ctx); err != nil {\n\t\t\terr = fmt.Errorf(\"sync replica for %s: %w\", db.Path(), err)\n\t\t\treturn\n\t\t}\n\n\t\t// Force a snapshot if requested.\n\t\tif c.forceSnapshot {\n\t\t\tslog.Info(\"taking snapshot\", \"path\", db.Path())\n\t\t\tif _, err = db.Snapshot(ctx); err != nil {\n\t\t\t\terr = fmt.Errorf(\"snapshot %s: %w\", db.Path(), err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Enforce retention if requested.\n\t\tif c.enforceRetention {\n\t\t\tslog.Info(\"enforcing retention\", \"path\", db.Path())\n\t\t\tif err = c.Store.EnforceSnapshotRetention(ctx, db); err != nil {\n\t\t\t\terr = fmt.Errorf(\"enforce retention for %s: %w\", db.Path(), err)\n\t\t\t\treturn","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/replicate.go#L391-L427","documentation":"ReplicateCommand.runOnce failed to sync the database's replica, i.e. uploading pending LTX files to remote storage failed. The wrapped error usually comes from the replica client's WriteLTXFile and indicates a storage backend I/O, auth, or connectivity problem during one-shot replication.","triggerScenarios":"Thrown at cmd/litestream/replicate.go:409 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the backend-specific cause (S3/GCS/ABS/NATS)","Verify credentials and network access to the replica destination","Re-run the one-shot replicate command; successfully-synced files are skipped on retry"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}