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:
- You must have
workstations.workstations.use
permission on the source workstation. - The Workstations Service Agent
for the project where you are creating the new workstation must have
compute.disks.createSnapshot
andcompute.snapshots.useReadOnly
on the project containing the source workstation.
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 \ --project=PROJECT \ --region=REGION \ --cluster=CLUSTER_NAME \ --config=CONFIG_NAME \ --source-workstation=SOURCE_WORKSTATION
Replace the following:
WORKSTATION
: the ID or fully qualified identifier for the new workstationPROJECT
: the project that will contain the new workstationREGION
: the region where the new workstation will reside—for example,us-central1
CLUSTER_NAME
: the name of the workstation cluster that will contain the new workstationCONFIG_NAME
: the name of the workstation configuration that will contain the new workstationSOURCE_WORKSTATION
: the fully qualified identifier of the source workstation from which the new workstation's persistent directories will be clonedYour source workstation's identifier 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 project containing the source workstationSOURCE_REGION
: the location where the source workstation residesSOURCE_CLUSTER
: the name of the workstation cluster that contains the source workstationSOURCE_CONFIG
: the name of the workstation configuration that contains the source workstationSOURCE_WORKSTATION
: the ID 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:
Create a new destination workstation using a configuration that specifies a larger persistent disk.
Start both the source workstation and the destination workstation.
Access a terminal on the destination workstation by launching it in the Google Cloud console or connecting to it using SSH.
From the terminal on the destination workstation, create a TCP tunnel to the source workstation using
gcloud workstations start-tcp-tunnel
.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_PORT
Replace the following:
WORKSTATION_PORT
: the port on the source workstation to which traffic should be sent (default:22
).LOCAL_PORT
(Optional): the localhost port from which traffic will be sent. Valid port numbers are1024
to65535
. If you omit the--local-host-port
flag or specify a port of0
an unused port is selected automatically.
When the tunnel is ready it will display the port number:
Listening on port [LOCAL_PORT].
In another terminal on the destination workstation, run
scp
and specify the port where the TCP tunnel is listening to copy the files from the source workstation.scp -rP LOCAL_PORT \ user@localhost:~/SOURCE_DIRECTORY \ ~/DESTINATION_DIRECTORY
Replace the following:
SOURCE_DIRECTORY
: the path to the directory to copy from the source workstationDESTINATION_DIRECTORY
: the path to the destination directory on the new workstation