You can backup your database automatically using this script
Here are the commands to manually do it via shell, given you have root privilege:
To dump the database onto a text file:
mysqldump database_name > database_name.sqlTo import the data into a database:
mysql database_name < database_name.sqlReplace database_name with the name of your database.
{ 1 comment… read it below or add one }
Use the –opt switch to dumpo with all the options. Below is an example how to dump a database from a script and then packing it in bzip2. Especially usefull if your databses get bigger
.
/usr/bin/mysqldump –user root –password=”password” -opt $db | bzip2 -c > ../dump/db.sql.bz2