Access restored virtual machine (VM) files through SSH by using rsync, scp, or sftp with the VirtualMachineFileRestore (VMFR) custom resource (CR). You can transfer files from VM backups efficiently.
When you configure SSH access, the VMFR controller autogenerates an SSH key pair and stores it in a Kubernetes secret. The default SSH username is oadp. The SSH file server listens on port 2222.
The remote path for restored files follows the format /restores/<date>/<backup_name>/<vm_name>/<path_to_file>.
Prerequisites
-
You are logged in to the cluster with the cluster-admin role.
-
You have created a VirtualMachineFileRestore (VMFR) CR with the fileAccess.ssh section configured.
-
The VMFR CR status.phase is Completed.
Procedure
-
To retrieve the SSH access information, run the following command:
$ oc get vmfr <vmfr_cr_name> -o jsonpath='{.status.fileServingInfo.ssh}' | jq
Replace <vmfr_cr_name> with the name of the VMFR CR. The output includes the clusterAccess URL and credentialsSecretRef containing the name and namespace of the generated SSH key secret.
-
Retrieve the private key from the generated secret and save it to a file:
$ oc get secret <secret_name> -n <secret_namespace> -o jsonpath='{.data.privateKey}' | base64 -d > id-rsa
Replace <secret_name> and <secret_namespace> with the values from the status.fileServingInfo.ssh.credentialsSecretRef field.
-
Set the correct permissions on the private key file:
-
Get the name of the file server service created in the VMFR namespace:
$ oc get svc -n <created_namespace> | grep fileserver
Replace <created_namespace> with the value from the status.createdNamespace field of the VMFR CR.
-
To copy a file from the backup by using scp, run the following command:
$ scp -P 2222 -i id-rsa \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
oadp@<fileserver_svc>.<created_namespace>.svc.cluster.local:<remote_path> \
<local_destination>
<fileserver_svc>
-
Specifies the name of the file server service.
<created_namespace>
-
Specifies the namespace from the status.createdNamespace field.
<remote_path>
-
Specifies the path to the file in the format /restores/<date>/<backup_name>/<vm_name>/<path_to_file>.
<local_destination>
-
Specifies the local file path to save the restored file.
-
To start an interactive SFTP session, run the following command:
$ sftp -P 2222 -i id-rsa \
-o StrictHostKeyChecking=no \
oadp@<fileserver_svc>.<created_namespace>.svc.cluster.local