Mysqldump is a simple, powerful backup utility for MySQL server. With this mysqldump command we can export or backup the entire MySQL server database with a single command. We can save the exported sql file into local directory or even we can save it to remote server via ssh.
This tutorial is going to show you how to perform MySQL backup using mysqldump command to remote ssh server. Before we go through, you will need the following information in hands:
- MySQL root password
- remote server access credentials (user name and password to login via ssh)
I would like to backup my MySQL databases to my remote server with IP address 10.34.0.10. Here is the command:
mysqldump -u root -p12345 --all-databases | gzip -c | ssh firstname.lastname@example.org "cat > /tmp/backup.sql.gz"
The command above execute mysqldump command with user root and password 12345. It will backup all the database on the MySQL Server and compress them using gzip into /tmp/backup.sql.gz file in 10.34.0.10 server.
Its pretty cool way to backup all the MySQL databases in a single command to a remote server via SSH. Try it.