Invoke–CopyRemoteToLocal - anongitmous/k8sShell GitHub Wiki
Copy files and directories from remote pods (containers) to a local destination.
[-Containers] <Mtf.Kubernetes.Models.V1K8sContainer[]>
-Source <String>
-Destination <String>
[-CreateChildDirectory]
[<K8sShellCommonParameters>]
[<CommonParameters>]
[-Pods] <Mtf.Kubernetes.Models.V1K8sPod[]>
[-ContainerName <String>]
-Source <String>
-Destination <String>
[-CreateChildDirectory]
[<K8sShellCommonParameters>]
[<CommonParameters>]
For every result of Get–Pods or Get–Containers piped into this cmdlet, the remote file or directory indicated by Source will be copied to the local directory indicated by Destination.
ℹ️ See A Note about the Examples
1. Copy the '/home' directory from every pod
- If the
ContainerNameargument is not supplied, then the source pods in this example must have a single container. If not, then the copy operation will fail for that pod.- Supplying the
CreateChildDirectoryswitch parameter creates child directories ofDestinationbased upon pod names.- Using aliasing, the above can be shortened to
ksgp | kscrl -s '/home' -d 'C:/Temp' -ccd
2. Copy the '/home' directory from every container in every pod
Get-Pods | Get-Containers | Invoke-CopyRemoteToLocal -Source '/home' -Destination 'C:/Temp' -CreateChildDirectory
- Supplying the
CreateChildDirectoryswitch parameter creates child directories ofDestinationbased upon pod and container names.- Using aliasing, the above can be shortened to
ksgp | ksgc | kscrl -s '/home' -d 'C:/Temp' -ccd
-Containers
- The container(s) resulting from a call to Get–Containers to copy from.
| Type: | Mtf.Kubernetes.Models.V1K8sContainer[] |
| Aliases: | |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
-Pods
- The pod(s) resulting from a call to Get–Pods to copy from.
| Type: | Mtf.Kubernetes.Models.V1K8sPod[] |
| Aliases: | |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
-ContainerName
- The name of the container to copy from.
- Specify along with the
-Podsparameter to specify which container to copy from when the pods have more than a single container.
| Type: | String |
| Aliases: | |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-Source
- Full path of the source file or directory on the remote filesystem.
| Type: | String |
| Aliases: | s |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-Destination
- Full path of the local destination directory to which remote file(s) are to be copied.
| Type: | String |
| Aliases: | d |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-CreateChildDirectory
- Switch parameter that controls whether child directories will be created within Destination.
- If pods are the input object, then the child directories will be named according to the 'pod_name'.
- If containers are the input object, then the child directories will be named according to 'pod_name/container_name'.
| Type: | SwitchParameter |
| Aliases: | ccd |
| Position: | Named |
| Default value: | False |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
K8sShell includes the following alias for Invoke-CopyRemoteToLocal:
- kscrl