Migrate to Containers CLI reference for Linux

m2c is a command-line tool that lets you set up and execute migrations on your local machine.

m2c

A command-line interface to Migrate to Containers.

Perform quick modernization for your workload by following a four step journey:

  1. Copy the file system from the source machine locally.

  2. Analyze the file system to create a modernization plan.

  3. Edit the plan to customize modernization artifacts.

  4. Generate the modernization artifacts.

Synopsis

m2c COMMAND [options]

Flags

-q,--quiet
Don't output anything
-v,--verbose
Show verbose output

Commands

Command Description
m2c analyze Analyze the workload's configuration in the given file system.
m2c cleanup Clean up a source file system.
m2c completion Generate the autocompletion script for the specified shell
m2c config View and edit configuration properties
m2c copy Copy a VM's file system locally.
m2c generate Generate migration artifacts from the given file system.
m2c help Help about any command
m2c migrate-data Migrate data from the local machine to PVCs.
m2c plugins Manage migration plugins
m2c version Print the CLI version.

m2c analyze

Analyze the workload's configuration in the given file system with a given plugin.

The resulting modernization plan will be available in the config.yaml file under the given output directory.

Synopsis

m2c analyze --source COPIED_FILESYSTEM_PATH --plugin PLUGIN_NAME --output OUTPUT_DIR [options]

Flags

-o,--output path
Output path that can be used as input to the m2c generate command
-r,--parameter name=value
Plugin analysis parameters in the format "name=value". Can be specified multiple times
-p,--plugin name
Plugin name
-s,--source path
The path to a file system generated by the m2c copy command
--volume localPath:remotePath
Bind mounts a file or directory into the container in the format of "localPath:remotePath". Can be specified multiple times

m2c cleanup

Clean up a source file system that was created by the copy command.

Synopsis

m2c cleanup -s SOURCE

Flags

-s,--source path
The path to the source created by m2c copy

m2c completion

Generate the autocompletion script for m2c for the specified shell.

See each sub-command's help for details on how to use the generated script.

Synopsis

m2c completion

Commands

Command Description
m2c completion bash Generate the autocompletion script for bash
m2c completion fish Generate the autocompletion script for fish
m2c completion powershell Generate the autocompletion script for powershell
m2c completion zsh Generate the autocompletion script for zsh

m2c completion bash

Generate the autocompletion script for the bash shell.

This script depends on the 'bash-completion' package.

If it is not installed already, you can install it via your OS's package manager.

To load completions in your current shell session:

    source <(m2c completion bash)

To load completions for every new session, execute once:

Linux:

    m2c completion bash > /etc/bash_completion.d/m2c

macOS:

    m2c completion bash > $(brew --prefix)/etc/bash_completion.d/m2c

You will need to start a new shell for this setup to take effect.

Synopsis

m2c completion bash

Flags

--no-descriptions
disable completion descriptions

m2c completion fish

Generate the autocompletion script for the fish shell.

To load completions in your current shell session:

    m2c completion fish | source

To load completions for every new session, execute once:

    m2c completion fish > ~/.config/fish/completions/m2c.fish

You will need to start a new shell for this setup to take effect.

Synopsis

m2c completion fish

Flags

--no-descriptions
disable completion descriptions

m2c completion powershell

Generate the autocompletion script for powershell.

To load completions in your current shell session:

    m2c completion powershell | Out-String | Invoke-Expression

To load completions for every new session, add the output of the above command

to your powershell profile.

Synopsis

m2c completion powershell

Flags

--no-descriptions
disable completion descriptions

m2c completion zsh

Generate the autocompletion script for the zsh shell.

If shell completion is not already enabled in your environment you will need

to enable it. You can execute the following once:

    echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions in your current shell session:

    source <(m2c completion zsh)

To load completions for every new session, execute once:

Linux:

    m2c completion zsh > "${fpath[1]}/_m2c"

macOS:

    m2c completion zsh > $(brew --prefix)/share/zsh/site-functions/_m2c

You will need to start a new shell for this setup to take effect.

Synopsis

m2c completion zsh

Flags

--no-descriptions
disable completion descriptions

m2c config

View and edit the configuration properties.

Synopsis

m2c config COMMAND

Commands

Command Description
m2c config get Print the value of a configuration property.
m2c config list Print all the configuration properties and their values.
m2c config set Set the value of a configuration property.
m2c config unset Reset a configuration property to its default value.

m2c config get

Print the value of a configuration property.

Synopsis

m2c config get KEY

m2c config list

Print all the configuration properties and their values.

Synopsis

m2c config list

m2c config set

Set the value of a configuration property.

Synopsis

m2c config set KEY VALUE

m2c config unset

Reset a configuration property to its default value.

Synopsis

m2c config unset KEY

m2c copy

Copy a VM's file system locally.

Copying is done through rsync and can be performed using gcloud or direct SSH.

Synopsis

m2c copy COMMAND

Commands

Command Description
m2c copy default-filters Show the default rsync filters used by the copy operation
m2c copy gcloud Copy a Google Cloud VM's file system locally over gcloud.
m2c copy ssh Copy a VM's filesystem to the local machine over ssh.

m2c copy default-filters

Show the default rsync filters used by the copy operation.

This can be used as a basis for a custom filters file to be provided via the --filters flag.

Synopsis

m2c copy default-filters

m2c copy gcloud

Copy a Google Cloud VM's file system locally over gcloud.

Synopsis

m2c copy gcloud -p,--project PROJECT_ID -z,--zone ZONE -n,--vm-name VM_NAME -o,--output OUTPUT_PATH [options]

Flags

--filters path
The path to a custom rsync filters file. Overrides the default filters
--internal-ip
Connect to instances using their internal IP addresses rather than their external IP addresses. Use this to connect from one instance to another on the same VPC network, over a VPN connection, or between two peered VPC networks. For this connection to work, you must configure your networks and firewall to allow SSH connections to the internal IP address of the instance to which you want to connect. To learn how to use this flag, see https://cloud.google.com/compute/docs/instances/connecting-advanced#sshbetweeninstances .
-o,--output path
Output path of the copied file system
-p,--project project
Google Cloud project
--remote-sudo
Use sudo on the remote side of rsync. Use this option if the credentials you pass are not for the root user. Not running as superuser prevents copying of the entire file system. Equivalent to passing --rsync-path 'sudo rsync' to rsync.
--tunnel-through-iap
Tunnel the ssh connection through Cloud Identity-Aware Proxy for TCP forwarding. To learn more, see the IAP for TCP forwarding documentation ( https://cloud.google.com/iap/docs/tcp-forwarding-overview ).
-n,--vm-name name
VM name
-z,--zone zone
Google Cloud zone

m2c copy ssh

Copy a VM's filesystem to the local machine over ssh.

Synopsis

m2c copy ssh [USER@]HOST -o,--output OUTPUT_PATH [options]

Flags

--filters path
The path to a custom rsync filters file. Overrides the default filters
-i,--identity-file key
A file containing the key for authentication
-o,--output path
Output path of the copied file system
--remote-sudo
Use sudo on the remote side of rsync. Use this option if the credentials you pass are not for the root user. Not running as superuser prevents copying of the entire file system. Equivalent to passing --rsync-path 'sudo rsync' to rsync.

m2c generate

Generate migration artifacts from the given file system.

This utilizes the migration plan configuration generated by a previous analyze operation.

Synopsis

m2c generate -i ANALYSIS_DIRECTORY -o OUTPUT_PATH [options]

Flags

-i,--input path
The path to a directory generated by "m2c analyze"
-o,--output path
The output path
--volume localPath:remotePath
Bind mounts a file or directory into the container in the format of "localPath:remotePath". Can be specified multiple times

m2c help

Help provides help for any command in the application.

Simply type m2c help [path to command] for full details.

Synopsis

m2c help [command]

m2c migrate-data

Migrate data from the local machine to PVCs on the currently connected cluster according to the data migration plan.

Synopsis

m2c migrate-data -i INPUT_PATH [options]

Flags

-i,--input path
The path to a directory generated by m2c analyze
-n,--namespace namespace
The namespace of the target PVCs on the target cluster

m2c plugins

Synopsis

m2c plugins COMMAND

Commands

Command Description
m2c plugins unpack Import plugins from a local file.

m2c plugins unpack

Import plugins from a local file.

To download a plugins bundle file, see https://cloud.google.com/migrate/containers/docs/m2c-cli/prepare-for-migration .

Synopsis

m2c plugins unpack -i,--input PATH [options]

Flags

-i,--input string
The path for the plugins file
-r,--registry string
A container registry that is available for the target cluster. Images used by the data migration process will be pushed to this registry to ensure data migration works without pulling images from the internet.

m2c version

Print the CLI version.

Synopsis

m2c version