Migrate applications
You can migrate your applications between clusters or storage classes by restoring your backup or snapshot data to a different cluster or storage class.
When you migrate an application, all execution hooks configured for the application are migrated with the app. If a post-restore execution hook is present, it runs automatically as part of the restore operation. |
Backup and restore operations
To perform backup and restore operations for the following scenarios, you can automate specific backup and restore tasks.
Clone to same cluster
To clone an application to the same cluster, create a snapshot or backup and restore the data to the same cluster.
-
Do one of the following:
-
On the same cluster, do one of the following, depending on if you created a snapshot or a backup:
Clone to different cluster
To clone an application to a different cluster (perform a cross-cluster clone), create a snapshot or backup and restore the data to a different cluster. Make sure that Trident protect is installed on the destination cluster.
-
Do one of the following:
-
Ensure that the AppVault CR for the object storage bucket that contains the backup or snapshot has been configured on the destination cluster.
-
On the destination cluster, do one of the following, depending on if you created a snapshot or a backup:
Migrate applications from one storage class to another storage class
You can migrate applications from one storage class to a different storage class by restoring a snapshot to the different destination storage class.
For example (excluding the secrets from the restore CR):
apiVersion: protect.trident.netapp.io/v1
kind: SnapshotRestore
metadata:
name: "${snapshotRestoreCRName}"
spec:
appArchivePath: "${snapshotArchivePath}"
appVaultRef: "${appVaultCRName}"
namespaceMapping:
destination: "${destinationNamespace}"
source: "${sourceNamespace}"
storageClassMapping:
destination: "${destinationStorageClass}"
source: "${sourceStorageClass}"
resourceFilter:
resourceMatchers:
kind: Secret
version: v1
resourceSelectionCriteria: exclude
-
Create the custom resource (CR) file and name it
trident-protect-snapshot-restore-cr.yaml
. -
In the file you created, configure the following attributes:
-
metadata.name: (Required) The name of this custom resource; choose a unique and sensible name for your environment.
-
spec.appArchivePath: The path inside AppVault where the snapshot contents are stored. You can use the following command to find this path:
kubectl get snapshots <my-snapshot-name> -n trident-protect -o jsonpath='{.status.appArchivePath}'
-
spec.appVaultRef: (Required) The name of the AppVault where the snapshot contents are stored.
-
spec.namespaceMapping: The mapping of the source namespace of the restore operation to the destination namespace. Replace
my-source-namespace
andmy-destination-namespace
with information from your environment.apiVersion: protect.trident.netapp.io/v1 kind: SnapshotRestore metadata: name: my-cr-name namespace: trident-protect spec: appArchivePath: my-snapshot-path appVaultRef: appvault-name namespaceMapping: [{"source": "my-source-namespace", "destination": "my-destination-namespace"}]
-
-
Optionally, if you need to select only certain resources of the application to restore, add filtering that includes or excludes resources marked with particular labels:
-
resourceFilter.resourceSelectionCriteria: (Required for filtering) Use
include or exclude
to include or exclude a resource defined in resourceMatchers. Add the following resourceMatchers parameters to define the resources to be included or excluded: -
resourceMatchers.group: (Optional) Group of the resource to be filtered.
-
resourceMatchers.kind: (Optional) Kind of the resource to be filtered.
-
resourceMatchers.version: (Optional) Version of the resource to be filtered.
-
resourceMatchers.names: (Optional) Names in the Kubernetes metadata.name field of the resource to be filtered.
-
resourceMatchers.namespaces: (Optional) Namespaces in the Kubernetes metadata.name field of the resource to be filtered.
-
resourceMatchers.labelSelectors: (Optional) Label selector string in the Kubernetes metadata.name field of the resource as defined in the Kubernetes documentation. For example:
"trident.netapp.io/os=linux"
.For example:
spec: resourceFilter: resourceSelectionCriteria: "include" resourceMatchers: group: my-resource-group kind: my-resource-kind version: my-resource-version names: ["my-resource-names"] namespaces: ["my-resource-namespaces"] labelSelectors: ["trident.netapp.io/os=linux"]
-
-
After you populate the
trident-protect-snapshot-restore-cr.yaml
file with the correct values, apply the CR:kubectl apply -f trident-protect-snapshot-restore-cr.yaml
-
Restore the snapshot to a different namespace, replacing values in brackets with information from your environment.
-
The
snapshot
argument uses a namespace and snapshot name in the format<namespace>/<name>
. -
The
namespace-mapping
argument uses colon-separated namespaces to map source namespaces to the correct destination namespaces in the formatsource1:dest1,source2:dest2
.For example:
tridentctl protect create snapshotrestore <my_restore_name> --snapshot <namespace/snapshot_to_restore> --namespace-mapping <source_to_destination_namespace_mapping>
-