1

I have a pod running two containers, one of them is mysql container. I want to take dbdump from mysql container running in the pod and save that file dbdump on my system.

So that dbdump is coming out to my system from container running inside a pod

mysqldump --user="user" --password="Password" abc_database > dbdump.sql
1

2 Answers 2

2

kubectl exec the command and redirect the output to a file. The redirection will occur locally on your system

kubectl exec deployment/mysql -- \
  mysqldump --user="user" --password="Password" abc_database > dbdump.sql
Sign up to request clarification or add additional context in comments.

Comments

2
  1. Login into the pod

kubectl exec -it <pod> -n <namespace> -- /bin/bash

  1. Run mysqldump from within the pod and use tmp to write the file

mysqldump <-u user> -p <db> > /tmp/file.sql

  1. Copy the file from the pod

kubectl cp <namespace>/<pod>:/tmp/file.sql file.sql

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.