MySQL Backup & Restore

Written by Peter Davies on .

This is a very simple command line based backup/copy procedure where on one machine (internal dev in my case) you do the following:

mysqldump -p webapp_dev_db > /home/dev/public/App/3rdJan09.sql

and on the external production:

mysql -v -p webapp_live_db < 3rdJan09.sql

In each case the command line apps use the "local" MySQL host and with the "-p" will prompt for a password. Adding and removing the "-v" will allow you to see if its actually doing something, for example on a db I'm working on this is 700Mb and it takes a while.

Keep in mind that MySQL records all inserts in the binary log, as a result you may find that your file system quickly runs out of space.