[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-19。"],[],[],null,["# Migrate data\n============\n\nThis page describes how to run a data migration that copies files from the\nlocal machine to a persistent volume claim (PVC) in the target cluster.\n\nThis is an optional step.\n\nCustomize your data migration configuration\n-------------------------------------------\n\nWhen you [complete an analysis](/migrate/containers/docs/m2c-cli/create-a-migration-plan),\nMigrate to Containers CLI might create a data configuration file named `dataConfig.yaml`\nin the specified analysis output directory. This indicates that to complete the\nmigration, you need to perform data migration.\n\nYou can also create this data configuration file manually for data migration,\nand provide information about your target data volume or data claim.\n\nFollowing is an example of a data configuration file: \n\n volumes:\n - deploymentPvcName: my-pvc1\n existingPvc:\n name: my-pvc1\n folders:\n - /bin\n - /opt\n - deploymentPvcName: my-pvc2\n newPvc:\n spec:\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: 10G\n folders:\n - /bin\n - /opt\n\nWhere:\n\n- `deploymentPvcName`: The PVC name to be used by Migrate to Containers\n in your deployed workload to access this volume.\n\n | **Note:** In case you've already [executed the migration](/migrate/containers/docs/m2c-cli/execute-the-migration-plan), if you change this PVC name in the data configuration file, ensure that you make the same change in the other migration artifacts, or execute the migration again to update the generated artifacts.\n- `existingPvc`:\n\n - `name`: Name of an existing persistent volume claim (PVC). Define if you want to migrate data volumes to an existing PVC.\n- `newPvc`: Define if you want to migrate your data volumes to a new PVC. You\n can define your PVC using the standard PVC spec syntax.\n\n For more information about Kubernetes PVC spec, see the [Kubernetes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/)\n documentation.\n | **Note:** You can migrate a data volume to either an existing PVC or a new PVC. Therefore, you must only define one of the two parameters, `existingPvc` or `newPvc`, per volume.\n- `folders`: the folder you want to migrate from the VM to PVC. These folders are\n copied to the PVC in the same path.\n\nYou can edit your data configuration file for several data migration use cases,\nincluding:\n\n- [Using an existing PVC](#use_an_existing_pvc)\n- [Creating new volumes on your migrated VM](#create_new_data_volumes_on_your_migrated_vms)\n- [Migrating multiple PVCs with multiple file paths](#migrate_multiple_pvcs_with_multiple_file_paths)\n\n### Use an existing PVC\n\nIf you've already allocated the storage for your migrated data, and have a\nPVC to store your data, you can migrate your data using an existing PVC.\n\nDefine an existing PVC in your data configuration file `dataConfig.yaml`\nby passing your existing volume in the `existingPvc` field. In this case, your\ndata configuration file would look like this: \n\n volumes:\n - deploymentPvcName: my-pvc\n existingPvc:\n name: my-pvc\n subpath: /subpath\n folders:\n - /bin\n - /opt\n\nIn the previous sample, the `existingPvc` entry can contain an optional\n`subPath` to migrate data to the subpath of the PVC, as shown.\n| **Note:** The PVC has to be in the same namespace as the target namespace on the deployment cluster.\n\n### Create new data volumes on your migrated VMs\n\nIf you've not allocated storage ahead of time, and you want your storage to be\ncreated during the migration process, you can pass an empty `existingPvc` field\nand specify the storage you would like to be created in the `newPvc` field: \n\n volumes:\n - deploymentPvcName: my-pvc\n newPvc:\n spec:\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: 10G\n folders:\n - /bin\n - /opt\n\n| **Note:** If you don't want to worry about the specifics of your backing storage, use an empty string for the storage class, as shown in the preceding yaml.\n\n### Migrate multiple PVCs with multiple file paths\n\nYou can specify the set of directories under the `folders` list field of each\nentry in the `volume` list for each PVC listed in your data configuration file\n`dataConfig.yaml`: \n\n volumes:\n - deploymentPvcName: my-pvc1\n existingPvc:\n name: my-pvc1\n folders:\n - /bin\n - /opt\n - deploymentPvcName: my-pvc2\n newPvc:\n spec:\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: 10G\n folders:\n - /bin\n - /opt\n\nThe paths you list under `folders` in the data configuration file are copied to\nthe same paths in the target PVCs.\n\nExecute the data migration\n--------------------------\n\nAfter you've customized your data configuration file `dataConfig.yaml`, to\nmigrate the data volumes to a PVC in the target cluster, run the following\ncommand: \n\n ./m2c migrate-data -i \u003cvar translate=\"no\"\u003eANALYSIS_OUTPUT_PATH\u003c/var\u003e -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eANALYSIS_OUTPUT_PATH\u003c/var\u003e: the path where you saved the [analysis\n output](/migrate/containers/docs/m2c-cli/create-a-migration-plan) that contains the file `dataConfig.yaml`\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the target Kubernetes cluster namespace of the deployed network\n\nWhat's next\n-----------\n\n- Learn how to [clean up your local machine](/migrate/containers/docs/m2c-cli/clean-up)."]]