Clone a workstation

You can quickly clone the content of an existing workstation when creating a new workstation. This can be helpful in certain cases when the region of the source workstation is experiencing instability.

Before you begin

Before you clone a workstation, make sure you have the right permissions to the source workstation:

  1. The user must have workstations.workstations.use permission on the source workstation.
  2. The workstation service account for the parent workstation cluster must have compute.disks.createSnapshot and compute.snapshots.useReadOnly on the source project.

Clone a workstation

To clone a workstation, create a new workstation and specify the source workstation that you want to copy:

    gcloud beta workstations create WORKSTATION \
      --cluster=CLUSTER_NAME \
      --config=CONFIG_NAME \
      --region=REGION \
      --source-workstation=SOURCE_WORKSTATION

Replace the following:

  • WORKSTATION: the ID of the workstation or fully qualified identifier for the workstation.

  • CLUSTER_NAME: the name of the workstation cluster containing the new workstation.

  • CONFIG_NAME: the name of the workstation configuration containing this new workstations.

  • REGION: the region where the workstation's cluster is located—for example, us-central1.

  • SOURCE_WORKSTATION: the path to the source workstation from which this workstation's persistent directories are cloned.

    Your source path might be similar to the following:

    projects/SOURCE_PROJECT/locations/SOURCE_REGION/workstationClusters/SOURCE_CLUSTER/workstationConfigs/SOURCE_CONFIG/workstations/SOURCE_WORKSTATION
    

    Replace the following:

    • SOURCE_PROJECT: the host project of the source workstation.
    • SOURCE_REGION: the location where the source workstation resides.
    • SOURCE_CLUSTER: the name of the workstation cluster that contains the source workstation.
    • SOURCE_CONFIG: the name of the workstation configuration that contains the source workstation.
    • SOURCE_WORKSTATION: the workstation name of the source workstation.

For more information, see gcloud beta workstations create.

For API reference information, see REST, and RPC.

How to copy content into a new workstation with a larger disk

Although you cannot expand the disk size of an existing workstation by cloning, you can copy the content to a workstation with a larger disk:

  1. Create a new workstation using a configuration that specifies a larger persistent disk.
  2. Create a TCP tunnel to the source workstation using gcloud workstations start-tcp-tunnel.
  3. Run scp and specify the TCP tunnel port to copy the files from the source workstation to the new one.

    # Start a tunnel from port of the source workstation to local host port on the new workstation
    gcloud workstations start-tcp-tunnel \
      --project=SOURCE_PROJECT --region=SOURCE_REGION --cluster=SOURCE_CLUSTER \
      --config=SOURCE_CONFIG SOURCE_WORKSTATION WORKSTATION_PORT --local-host-port=:LOCAL_HOST_PORT
    
    # Reference the TCP tunnel port to copy the files
    scp -P LOCAL_HOST_PORT -r user@localhost:~/SOURCE_DIRECTORY ~/DESTINATION_DIRECTORY
    

    Replace the following:

    • SOURCE_DIRECTORY: the path to the source workstation.
    • DESTINATION_DIRECTORY: the path to the destination workstation.
    • WORKSTATION_PORT: the port on the workstation to which traffic should be sent.
    • LOCAL_HOST_PORT: default="localhost:0". LOCAL_PORT on which Google Cloud CLI should bind and listen for connections that should be tunneled. If it is 0, an arbitrary unused local port is chosen.