copyprojectrefs

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "copy-project-refs <source-scope>",
	Short: "Copy project record references to another Syfon instance",
	Long: `Copy the exact Syfon records for one source scope to another Syfon instance.

The source scope is the org/project you are copying from, written as <organization>/<project-id>.

Use source-prefixed auth flags for the source Syfon instance:
  --source-profile
  --source-token
  --source-basic-user / --source-basic-password

Use target-prefixed auth flags for the destination Syfon instance:
  --target-profile
  --target-token
  --target-basic-user / --target-basic-password

For example, in:
  syfon copy-project-refs Ellrott_Lab/embedding_rotation --source-profile calypr-dev --target-server https://other-calypr.example --target-profile calypr-prod

the source scope is Ellrott_Lab/embedding_rotation.

This command copies metadata only: DID, access methods, controlled_access, hashes, filenames, size, description, version, and related record fields. It does not copy file bytes or modify bucket mappings.`,
	Example: `  syfon copy-project-refs Ellrott_Lab/embedding_rotation --source-profile calypr-dev --target-server https://other-calypr.example --target-profile calypr-prod
  syfon copy-project-refs Ellrott_Lab/embedding_rotation --target-server https://other-calypr.example -I fb4284fe-2c39-5939-bae9-69c4bf4c608a`,
	Args: cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := cmd.Context()

		scope, err := projectcopy.ParseScopeArg(args[0], "source")
		if err != nil {
			return err
		}

		sourceClient, _, err := copyFlags.NewSourceClient(ctx, cmd)
		if err != nil {
			return err
		}
		targetClient, targetServer, err := copyFlags.NewTargetClient(ctx, cmd, false, false)
		if err != nil {
			return err
		}

		records, err := projectcopy.RecordsToCopy(ctx, cmd, sourceClient.Index(), scope, copyFlags.IndividualDID)
		if err != nil {
			return err
		}
		fmt.Fprintf(cmd.OutOrStdout(), "Found %d records to copy.\n", len(records))

		for i, rec := range records {
			fmt.Fprintf(cmd.OutOrStdout(), "[%d/%d] Copying record %s...\n", i+1, len(records), rec.Did)
			if err := upsertExactRecord(ctx, targetClient.Index(), rec); err != nil {
				return fmt.Errorf("failed to copy record %s: %w", rec.Did, err)
			}
		}

		fmt.Fprintf(cmd.OutOrStdout(), "Successfully copied %d records for %s to %s.\n", len(records), args[0], strings.TrimRight(strings.TrimSpace(targetServer), "/"))
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL