gcloud database-migration migration-jobs generate-ssh-script - generate a SSH script for a Database Migration Service migration job
gcloud database-migration migration-jobs generate-ssh-script (MIGRATION_JOB : --region=REGION) --vm=VM (--vm-zone=VM_ZONE | [--subnet=SUBNET --vm-machine-type=VM_MACHINE_TYPE : --vm-zone-create=VM_ZONE_CREATE]) [--vm-port=VM_PORT] [GCLOUD_WIDE_FLAG ...]
Generate a script for a Database Migration Service migration job, to configure Reverse SSH tunnel connectivity with a bastion host on a Compute Engine VM instance. You can use an existing VM instance or create a new VM for this purpose.
Copy the generated script and run it in bash from a machine that has:
The gcloud command-line tool installed.
Access to your source database.
Access to the existing bastion VM, or permissions and access to the Cloud Compute API if creating a new bastion VM. Make sure this machine is available during the entire migration.
Running the script will set up the SSH tunnel on the VM you selected and will establish connectivity between the source database and the Cloud SQL instance. Find additional information here https://cloud.google.com/database-migration/docs/mysql/configure-connectivity-reverse-ssh-tunnel.
To generate an SSH script with bastion VM instance creation:
$ gcloud database-migration migration-jobs generate-ssh-script \ my-migration-job --vm=vm1 --vm-port=1111 \ --vm-machine-type=n1-standard-1 --vm-zone-create=us-central1-a \ --subnet=sample-subnet --region=us-central1
To generate an SSH script with an existing bastion VM instance:
$ gcloud database-migration migration-jobs generate-ssh-script \ my-migration-job --vm=vm1 --vm-port=1111 \ --vm-zone=us-central1-a --region=us-central1
- Migration job resource - The migration job to generate the SSH script for. The
arguments in this group can be used to specify the attributes of this resource. (NOTE) Some attributes are not given arguments in this group but can be set in other ways. To set the project attribute:
- —
provide the argument migration_job on the command line with a fully specified name;
- —
provide the argument --project on the command line;
- —
set the property core/project.
This must be specified.
- MIGRATION_JOB
ID of the migration_job or fully qualified identifier for the migration_job. To set the migration_job attribute:
provide the argument migration_job on the command line.
This positional argument must be specified if any of the other arguments in this group are specified.
- --region=REGION
The name of the region. To set the region attribute:
provide the argument migration_job on the command line with a fully specified name;
provide the argument --region on the command line.
- --vm=VM
Bastion Compute Engine VM instance name to use or to create.
- Exactly one of these must be specified:
- --vm-zone=VM_ZONE
Zone the existing bastion VM instance is located in.
- --subnet=SUBNET
Subnet to create the VM instance in.
This flag argument must be specified if any of the other arguments in this group are specified.
- --vm-machine-type=VM_MACHINE_TYPE
Machine type for a new VM instance. To get a list of available machine types, run 'gcloud compute machine-types list'.
This flag argument must be specified if any of the other arguments in this group are specified.
- --vm-zone-create=VM_ZONE_CREATE
Zone to create the VM instance in.
- --vm-port=VM_PORT
Port that will be open on the bastion host.
These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.
Run $ gcloud help for details.
This command uses the datamigration/v1 API. The full documentation for this API can be found at: https://cloud.google.com/database-migration/
This variant is also available:
$ gcloud alpha database-migration migration-jobs generate-ssh-script