Daily Archives: July 8, 2019

Pipe mysqldump to ssh/sftp

If you need to send mysqldump over ssh on different server without creating any files on the local server, mostly if you are low on space you can use this:

mysqldump -u MYSQL_USERNAME -p DATABASE | gzip -c | ssh USER@HOST 'cat > ~/dump.sql.gz'


And for the restore from remote location:
ssh USER@HOST "cat /path/to/db.sql" | mysql -uUSER  -pPASSWORD DATABASE