Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqldump from remote host

Tags:

linux

mysql

ssh

Is it possible to dump a database from a remote host through an ssh connection and have the backup file on my local computer.

If so how can this be achieved?

I am assuming it will be some combination of piping output from the ssh to the dump or vice versa but cant figure it out.

like image 405
Marty Wallace Avatar asked Nov 27 '12 23:11

Marty Wallace


1 Answers

This would dump, compress and stream over ssh into your local file

ssh -l user remoteserver "mysqldump -mysqldumpoptions database | gzip -3 -c" > /localpath/localfile.sql.gz  
like image 200
Michel Feldheim Avatar answered Oct 04 '22 22:10

Michel Feldheim