Migrate data
This page describes how to run a data migration that copies files from the local machine to a persistent volume claim (PVC) in the target cluster.
This is an optional step.
Customize your data migration configuration
When you complete an analysis,
Migrate to Containers CLI might create a data configuration file named dataConfig.yaml
in the specified analysis output directory. This indicates that to complete the
migration, you need to perform data migration.
You can also create this data configuration file manually for data migration, and provide information about your target data volume or data claim.
Following is an example of a data configuration file:
volumes:
- deploymentPvcName: my-pvc1
existingPvc:
name: my-pvc1
folders:
- /bin
- /opt
- deploymentPvcName: my-pvc2
newPvc:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10G
folders:
- /bin
- /opt
Where:
deploymentPvcName
: The PVC name to be used by Migrate to Containers in your deployed workload to access this volume.existingPvc
:name
: Name of an existing persistent volume claim (PVC). Define if you want to migrate data volumes to an existing PVC.
newPvc
: Define if you want to migrate your data volumes to a new PVC. You can define your PVC using the standard PVC spec syntax.For more information about Kubernetes PVC spec, see the Kubernetes documentation.
folders
: the folder you want to migrate from the VM to PVC. These folders are copied to the PVC in the same path.
You can edit your data configuration file for several data migration use cases, including:
- Using an existing PVC
- Creating new volumes on your migrated VM
- Migrating multiple PVCs with multiple file paths
Use an existing PVC
If you've already allocated the storage for your migrated data, and have a PVC to store your data, you can migrate your data using an existing PVC.
Define an existing PVC in your data configuration file dataConfig.yaml
by passing your existing volume in the existingPvc
field. In this case, your
data configuration file would look like this:
volumes:
- deploymentPvcName: my-pvc
existingPvc:
name: my-pvc
subpath: /subpath
folders:
- /bin
- /opt
In the previous sample, the existingPvc
entry can contain an optional
subPath
to migrate data to the subpath of the PVC, as shown.
Create new data volumes on your migrated VMs
If you've not allocated storage ahead of time, and you want your storage to be
created during the migration process, you can pass an empty existingPvc
field
and specify the storage you would like to be created in the newPvc
field:
volumes:
- deploymentPvcName: my-pvc
newPvc:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10G
folders:
- /bin
- /opt
Migrate multiple PVCs with multiple file paths
You can specify the set of directories under the folders
list field of each
entry in the volume
list for each PVC listed in your data configuration file
dataConfig.yaml
:
volumes:
- deploymentPvcName: my-pvc1
existingPvc:
name: my-pvc1
folders:
- /bin
- /opt
- deploymentPvcName: my-pvc2
newPvc:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10G
folders:
- /bin
- /opt
The paths you list under folders
in the data configuration file are copied to
the same paths in the target PVCs.
Execute the data migration
After you've customized your data configuration file dataConfig.yaml
, to
migrate the data volumes to a PVC in the target cluster, run the following
command:
./m2c migrate-data -i ANALYSIS_OUTPUT_PATH -n NAMESPACE
Replace the following:
- ANALYSIS_OUTPUT_PATH: the path where you saved the analysis
output that
contains the file
dataConfig.yaml
- NAMESPACE: the target Kubernetes cluster namespace of the deployed network
What's next
- Learn how to clean up your local machine.