Backing up your Database
In this section, we’ll look at how to backup and restore MySQL database, since this is the most popular database used in UNIX and Linux system. It is important that your database is backed up every other week in order to avoid mishaps in the event of system crashes.
Backing up database is often performs at every week or so, depending on your usage. If your system is running 24/7 and managed at least 20 clients then I suggest that you should backup your database every few days to prevent it from an unplanned disaster.
MySQLdump Command:
The MySQLdump Command is a command that creates a text version of the database. Specifically, it creates a list of SQL statements which can be used to restore or create the original data.

You can do this by using the Bash Shell as shown below:
As you can see, first is the mysqldump command then the scripts:
[database_username] – is the user name for your database.
[database_password] – is the password for your database.
[database_name] – is the name of your database.
[backupfile.sql] – is the backup database file.

To dump all MySQL database we would have to add (--all-databases) command.
Restoring MySQL Database:

To rebuild the database from scratch use the command below:
Mysql –u [username] –p [password] [database-to-restore] < [backupfile]
Use this command to import into an existing database:

Mysqlimport [options] database database_name
April, 27 2009
By: William Nguyen

