There are a lot of scripts at which allow you to back up your database such as PhpMyadmin (
http://www.phpmyadmin.net/home_page/downloads.php), mysqldumper (
http://www.mysqldumper.de/) and etc... those are 2 of the best scripts for backing up your database.
But i have a better way (in my opinion)
Since having those php scripts i have to be careful about secure those script, security with open source software is a big issue, i intend to make things as simple as possible.
The beauty of Linux is giving you the Freedom, you can do whatever you want almost everything from just a command line interface.
you're hopeless with Windows servers.
lets get down to backing up business:
in Ubuntu i use mysqldump to back up database. to back up a specific database i use:
Code:
mysqldump --opt -uUSER -pPassword -hHOST DATABASE > /home/user/direcroty/to/backup_db.sql
Replase USER with your mysql username, Password with your password, HOST to servername and DATABASE to your database name
ex:
Code:
mysqldump --opt -unguyen -phlugcouk -hlocalhost forum > /home/user/direcroty/to/backup_db.sql
to avoid override daily backup you can add "
$(date)" to the file name
ex:
Code:
mysqldump --opt -unguyen -phlugcouk -hlocalhost forum > /home/user/direcroty/to/backup_db$(date).sql
out put would look like this:
"backup_db Thu Feb 18 03:40:10 CET 2010.sql"if you want to compress it to save space:
Code:
mysqldump -unguyen -phlugcouk -hlocalhost forum | gzip > /home/user/direcroty/to/backup_db$(date).sql.gz
out put would look like this:
"backup_db Thu Feb 18 03:40:10 CET 2010.sql.gz"to un pack the file *.gz :
Code:
gzip -d /home/user/direcroty/to/backup_db.sql.gz
-------------------------------
now you have done the backing up, what about restore it?
simple
open your CLI:
connect to mysql server:
Code:
#mysql -uYouruser -hlocalhost -p
type in your password then you can see something like this:
Code:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47719
Server version: 5.1.37-1ubuntu5.1 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
now type
Code:
#use database;
change database to database you wanna restore
now do the restore:
Code:
#source > /home/user/direcroty/to/backup_db.sql
that's it type
\q to exist mysql.