Making MySQL backups
by sabitha[ Edit ] 2010-11-30 11:42:18
The command line utility program for backing up MySQL databases and tables to .sql files is called mysqldump. It is described in the MySQL documentation. I won't try to supplement it here except to show an example command that I used in Ubuntu Linux to back up all databases and tables and send the result through the gzip program to compress it:
mysqldump -uroot -p --verbose --all-databases --hex-blob --skip-extended-insert | gzip > my-databases-backup.sql.gz
I'm not sure I chose the exact best combination of options, and I should have done each database individually, because the file containing all of them turned out to be nearly 800MB, but I just wanted to quickly backup everything before doing something risky.
However, the example demonstrates something important: it might seem like a real pain to carefully study a huge long list of options in the documentation and gradually build the text-mode command to perform a particular task, but once it's done, it's done. You can save the command for later. From then on, using it is very simple, much simpler than trying to remember which bunch of dialog-box options and checkboxes you used previously when working in a GUI. I favor and promote using text mode programs over GUIs when possible, and this is one of the reasons. Using a GUI for what is basically a text mode task is inefficient and more confusing rather than less (except at first!).