{"record":{"id":"6265cd9146445162","repo":"kopia/kopia","slug":"sync-only-supports-directly-connected-repositories","errorCode":null,"errorMessage":"sync only supports directly-connected repositories","messagePattern":"sync only supports directly-connected repositories","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_repository_sync.go","lineNumber":74,"sourceCode":"\t\tcc := cmd.Command(prov.Name, \"Synchronize repository data to another repository in \"+prov.Description)\n\t\tf.Setup(svc, cc)\n\t\tcc.Action(func(kpc *kingpin.ParseContext) error {\n\t\t\treturn svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {\n\t\t\t\tst, err := f.Connect(ctx, false, 0)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"can't connect to storage\")\n\t\t\t\t}\n\n\t\t\t\trep, err := svc.openRepository(ctx, true)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"open repository\")\n\t\t\t\t}\n\n\t\t\t\tdefer rep.Close(ctx) //nolint:errcheck\n\n\t\t\t\tdr, ok := rep.(repo.DirectRepository)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn errors.New(\"sync only supports directly-connected repositories\")\n\t\t\t\t}\n\n\t\t\t\treturn c.runSyncWithStorage(ctx, dr.BlobReader(), st)\n\t\t\t})\n\t\t})\n\t}\n}\n\nconst syncProgressInterval = 300 * time.Millisecond\n\nfunc (c *commandRepositorySyncTo) runSyncWithStorage(ctx context.Context, src blob.Reader, dst blob.Storage) error {\n\tlog(ctx).Info(\"Synchronizing repositories:\")\n\tlog(ctx).Infof(\"  Source:      %v\", src.DisplayName())\n\tlog(ctx).Infof(\"  Destination: %v\", dst.DisplayName())\n\n\tif !c.repositorySyncDelete {\n\t\tlog(ctx).Info(\"NOTE: By default no BLOBs are deleted, pass --delete to allow it.\")\n\t}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_repository_sync.go#L56-L92","documentation":"Repository synchronization (`repository sync to ...`) reads blobs directly from the source repository. The opened rep is type-asserted to repo.DirectRepository; server/API-backed connections do not implement it, so the sync command refuses to proceed.","triggerScenarios":"Running `kopia repository sync to ...` while connected to a kopia server (or any non-direct repository). The type assertion `dr, ok := rep.(repo.DirectRepository)` fails at cli/command_repository_sync.go:74.","commonSituations":"Being connected to a kopia server in the current context and attempting to sync; assuming sync works over the server API; running sync in an environment where the default connection is server-based.","solutions":["Connect directly to the underlying storage first (e.g. `kopia repository connect filesystem/s3 ...`) and then run the sync command.","Use a direct repository URL via --repository-url if supported, bypassing the server connection.","If data must move off a server, perform the sync from a client with direct storage credentials."],"exampleFix":"// before (server connection active)\nkopia repository sync to s3 --bucket mybucket\n// after (connect directly first)\nkopia repository connect s3 --bucket mybucket --access-key ... && kopia repository sync to s3 --bucket mybucket","handlingStrategy":"validation","validationCode":"// ensure a direct connection before syncing\nif connectedViaServer() {\n  return errors.New(\"reconnect directly to storage before running sync\")\n}","typeGuard":"func isDirectRepository(rep repo.Repository) (repo.DirectRepository, bool) {\n  dr, ok := rep.(repo.DirectRepository)\n  return dr, ok\n}","tryCatchPattern":null,"preventionTips":["Run sync commands only from clients with direct storage credentials, never through `connect server` sessions.","Check `kopia repository status` for connection type before scripting sync."],"tags":["cli","sync","server-connection"],"backgroundTag":"unsupported-operation","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}