Skip to content

Instantly share code, notes, and snippets.

@mrintegrity
Forked from kirkegaard/dumpoverssh.sh
Created September 26, 2012 08:15
Show Gist options
  • Save mrintegrity/3786733 to your computer and use it in GitHub Desktop.
Save mrintegrity/3786733 to your computer and use it in GitHub Desktop.
pipe a mysql dump through gzip and send it over ssh
mysqldump -u MYSQL_USERNAME -p YOUR_DATABASE | gzip -c | ssh USERNAME@YOUR_TO_HOST 'cat > ~/dump.sql.gz'
@DavidGoodwin
Copy link

DavidGoodwin commented Oct 5, 2017

Or .... assuming you're on Debian/Ubuntu which has /etc/mysql/debian.cnf with credentials in it ...

ssh USERNAME@FROM_SERVER 'mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --add-drop-tables --databases db1 db2 db3 | gzip -c ' | zcat -d | mysql --defaults-extra-file=/etc/mysql/debian.cnf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment