= SOP Velero
This SOP should be used in the following scenario:

- Performing a data migration between OpenShift clusters.
- Performing a data backup to S3
- Velero doesn't support restoring into a cluster with a lower Kubernetes version than where the backup was taken.

== Resources
- [1] https://velero.io/docs/main/migration-case/[Migrating between OpenShift clusters using Velero]


== Steps
1. Install the Velero CLI client.
+
eg:
+
----
wget https://github.com/vmware-tanzu/velero/releases/download/v1.8.1/velero-v1.8.1-linux-amd64.tar.gz
tar -zxf velero-v1.8.1-linux-amd64.tar.gz
ln -s velero-v1.8.1-linux-amd64/velero ~/bin/velero
----


2. Configure Velero to access S3
+
Create a file `credentials-velero` which contains the AWS access key and secret access key with permissions to access an S3 bucket.
+
----
[default]
aws_access_key_id=XXX
aws_secret_access_key=XXX
----


3. Next install Velero in the cluster
+
Ensure you are authenticated to the OpenShift cluster via the CLI.
+
Using something like the following:
+
----
REGION="us-east-1"
S3BUCKET="fedora-openshift-migration"

velero install \
    --provider aws \
    --plugins velero/velero-plugin-for-aws:v1.4.0 \
    --bucket $S3BUCKET \
    --backup-location-config region=$REGION \
    --snapshot-location-config region=$REGION \
    --use-volume-snapshots=true \
    --image velero/velero:v1.4.0  \
    --secret-file ./credentials-velero \
    --use-restic
----

4. Perform a backup
+
eg:
+
----
velero backup create backupName --include-cluster-resources=true --ordered-resources 'persistentvolumes=pvName' --include-namespaces=namespaceName
----


5. Restore a backup
+
While authenticated to a second cluster to restore to, or original cluster where you are recovering to you can restore a backup like so:
+
----
velero backup get
velero restore create --from-backup backupName
----

For more information see the `Velero` documentation at [1].

