How to Backup MySQL on a Website

Usually, a web host will give you FTP access to a directory and a web interface. A button in the web interface will produce a .ZIP file with the database contents, and you can download it via FTP.

If you have shell access, and you run a Unix at home, and develop your own website, you can use this script. It dumps the remote database, and then loads it into a local copy of your database.

#! /bin/bash

echo Dumping db to db.mysql.
echo Type your password.
ssh mysqldump -u uname '-p--remotepw---' database_name  > db.mysql
echo Loading
mysql -u root '-p----password----' database_name < db.mysql

It's really just two lines of typing, but having it scripted is nice.