Why can't copy a file from pod to my local

Viewed 2317

I know this question asked before and I checked them but still fails.

Pod name : postgresl-7c8b9-qs67z

File in the pod : /home/backup/db

So I want to try to copy "db" file to my local and I tried to commands below, but all of them giving the same error.

 kubectl cp default/postgresl-7c8b9-qs67z:/home/backup/db C:\Users\myuser\Desktop\mydb1.dmp

 kubectl cp default/postgresl-7c8b9-qs67z:/home/backup/ C:\Users\myuser\Desktop\

 kubectl cp postgresl-7c8b9-qs67z:/home/backup/db C:\Users\myuser\Desktop\mydb1.dmp

And the error is :

error: one of src or dest must be a local file specification

How can I do that? Thanks!

2 Answers

Currently there seems to be a bug in kubectl where C: is treaten as the pod name.

Just use a relative path for your local file. E.g:

kubectl cp default/postgresl-7c8b9-qs67z:/home/backup/db ./Desktop/mydb1.dmp

additional hint:

If you receive a tar: Removing leading '/' from member names, check if the file was downloaded anyhow.

I my case, I have

  • a namespace called test

  • a pod called pod-aabbcc

  • a folder inside pod: /myfolder/files/pdf/ it has several files

  • my environment run in c:\users\naldo

  • I will run

    kubectl cp -n test pod-aabbcc:/myfolder/files/pdf/ ./salidaPDF/

The console throws the message: tar: removing leading '/' from member names, but you can skip that message.

In c:\users\naldo, automatically kubectl create the folfer /salidaPDF/

c:\users\naldo\salidaPDF

and inside are copied all files.

Related