hyper-vdocker-containerfile-copyingazure-iot-edgedocker-cp

Copy HyperVM Iotedge docker container offline files into Local Drive


I'm having a Windows 10 host with Hyper-V Linux VM having IOT EdgeAgent and EdgeHub modules installed. I have provided storageFolder mount to EdgeAgent & Hub to store offline files at var/iotedge/storage location in EdgeHub container.

I would like to run docker command to copy this nested VM container files with host Windows local C:/TempEdge folder.

Step 1: Using "connect-eflowVM" command to connect to IotEdge VM Step 2: sudo docker cp EdgeHub:/var/iotedge/storage "c:/TempEdge"

But it's treating 'c' as another container and throwing cannot copy between container error.

I have tried replacing "c:/TempEdge" with "//c/TempEdge" and "c/TempEdge"

But then it throws no such file directory error.

What will be the correct format or way to run this query in EflowVM (hyper-V) and copy data to host Windows C drive

Edit: Adding message for No such file or directory error

PS C:\Windows\system32> Copy-EflowVmFile -fromFile "C:\Users\XXXXXXX\TempEdge" -toFile "blobStorage" scp failed to execute [scp: C:/Users/XXXXXXX/TempEdge: No such file or directory] At C:\Program Files\WindowsPowerShell\Modules\AzureEFLOW\AzureEFLOW.psm1:4349 char:9

+throw "$command $arguments failed to execute [$err]" +CategoryInfo : OperationStopped: (scp failed to ...e or directory]:String) [], RuntimeException +FullyQualifiedErrorId : scp failed to execute [scp:C:/Users/XXXXXXX/TempEdge: No such file or directory


Solution

  • I followed this link to Use PowerShell functions for Azure IoT Edge for Linux on Windows with Copy-EflowVmFile.

    Prerequisites:

    1. Set Execution Policy:
      • Set the execution policy on the target device to at least AllSigned using the Set-ExecutionPolicy PowerShell command.

    The Copy-EflowVmFile command is a function designed to copy files to or from a virtual machine utilizing the Secure Copy Protocol (SCP).

    Copy-EflowVmFile:

    Copy-EflowVmFile -fromFile "localpathtosource/file.txt" -toFile "remotepathonvm/file.txt" -pushFile
    

    For detailed information about the command, use the Get-Help command:

    Get-Help Copy-EflowVMFile -Full
    

    Enter image description here

    The Connect-EflowVm command establishes an SSH connection to the virtual machine.

    Connect-EflowVm
    

    Ensure that you create the folder in EFlow prior to executing the Copy-EflowVmFile command.

    mkdir Folder
    

    Enter image description here