// Module included in the following assemblies:
//
// * migrating_from_ocp_3_to_4/troubleshooting-3-4.adoc
// * migration_toolkit_for_containers/troubleshooting-mtc

:_mod-docs-content-type: PROCEDURE
[id="migration-rolling-back-migration-cli_{context}"]
= Rolling back a migration from the command line interface

You can roll back a migration by creating a `MigMigration` custom resource (CR) from the command line interface.

[NOTE]
====
The following resources remain in the migrated namespaces for debugging after a failed direct volume migration (DVM):

* Config maps (source and destination clusters)
* `Secret` objects (source and destination clusters)
* `Rsync` CRs (source cluster)

These resources do not affect rollback. You can delete them manually.

If you later run the same migration plan successfully, the resources from the failed migration are deleted automatically.
====

If your application was stopped during a failed migration, you must roll back the migration to prevent data corruption in the persistent volume.

Rollback is not required if the application was not stopped during migration because the original application is still running on the source cluster.

.Procedure

. Create a `MigMigration` CR based on the following example:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: migration.openshift.io/v1alpha1
kind: MigMigration
metadata:
  labels:
    controller-tools.k8s.io: "1.0"
  name: <migmigration>
  namespace: openshift-migration
spec:
...
  rollback: true
...
  migPlanRef:
    name: <migplan> <1>
    namespace: openshift-migration
EOF
----
<1> Specify the name of the associated `MigPlan` CR.

. In the {mtc-short} web console, verify that the migrated project resources have been removed from the target cluster.
. Verify that the migrated project resources are present in the source cluster and that the application is running.
