Atul Chandra
Atul Chandra

Reputation: 25

copying file from a pod to local machine directly from inside the pod

Is it possible to copy a file from kubernetes pod to local directly from inside the pod? Actually I am trying to take a db dump and copy it directly to my local. But unable to do it in a single command. command is as below:

kubectl --kubeconfig kubeconfig.yaml exec -n mysql_pod -- mysqldump -uroot -p --databases > new_bkp.sql && kubectl cp /mysql_pod:new_bkp.sql /home/atul/Desktop/new_bkp.sql

It is working fine for me. But is there anyway so that I can directly copy it to my local machine without using second command with the help of &&?

Upvotes: 1

Views: 1418

Answers (1)

Saya Kasta
Saya Kasta

Reputation: 160

Yes, you can

$ kubectl --kubeconfig kubeconfig.yaml exec pod_name  -n namespace -- mysqldump -u root -ppassword databasename > location/file_name.sql

Upvotes: 1

Related Questions