kopia/kopia · error

sync only supports directly-connected repositories

Error message

sync only supports directly-connected repositories

What it means

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.

Solutions

  1. Connect directly to the underlying storage first (e.g. `kopia repository connect filesystem/s3 ...`) and then run the sync command.
  2. Use a direct repository URL via --repository-url if supported, bypassing the server connection.
  3. If data must move off a server, perform the sync from a client with direct storage credentials.

Example fix

// before (server connection active)
kopia repository sync to s3 --bucket mybucket
// after (connect directly first)
kopia repository connect s3 --bucket mybucket --access-key ... && kopia repository sync to s3 --bucket mybucket
Defensive patterns

Strategy: validation

Validate before calling

// ensure a direct connection before syncing
if connectedViaServer() {
  return errors.New("reconnect directly to storage before running sync")
}

Type guard

func isDirectRepository(rep repo.Repository) (repo.DirectRepository, bool) {
  dr, ok := rep.(repo.DirectRepository)
  return dr, ok
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07). Data as JSON: /api/errors/6265cd9146445162. Report an issue: GitHub.

Appendix: source

Thrown at cli/command_repository_sync.go:74

		cc := cmd.Command(prov.Name, "Synchronize repository data to another repository in "+prov.Description)
		f.Setup(svc, cc)
		cc.Action(func(kpc *kingpin.ParseContext) error {
			return svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {
				st, err := f.Connect(ctx, false, 0)
				if err != nil {
					return errors.Wrap(err, "can't connect to storage")
				}

				rep, err := svc.openRepository(ctx, true)
				if err != nil {
					return errors.Wrap(err, "open repository")
				}

				defer rep.Close(ctx) //nolint:errcheck

				dr, ok := rep.(repo.DirectRepository)
				if !ok {
					return errors.New("sync only supports directly-connected repositories")
				}

				return c.runSyncWithStorage(ctx, dr.BlobReader(), st)
			})
		})
	}
}

const syncProgressInterval = 300 * time.Millisecond

func (c *commandRepositorySyncTo) runSyncWithStorage(ctx context.Context, src blob.Reader, dst blob.Storage) error {
	log(ctx).Info("Synchronizing repositories:")
	log(ctx).Infof("  Source:      %v", src.DisplayName())
	log(ctx).Infof("  Destination: %v", dst.DisplayName())

	if !c.repositorySyncDelete {
		log(ctx).Info("NOTE: By default no BLOBs are deleted, pass --delete to allow it.")
	}

View on GitHub (pinned to 82495e54b5)