At 14:13 +0200 15-11-2003, Davut Topcan wrote:
> I have just started working on MYSQL.
Can ne one help on How to take a database Backup?

Backup; shell # mysqldump table > table.sql


I use a command-line PHP script (-rwx------, owned by root, executed with a cron job) to backup MySQL databases. Something along these lines:

==========================================================
#!/usr/bin/php -q

<?php

$user = 'root';
$password = 'secret';
$connection = mysql_connect('localhost', $user, $password);
$databases = mysql_list_dbs($connection);


while ($database_row = mysql_fetch_row($databases)) {


$database = $database_row[0];
if (! file_exists("/tmp/backup/sql/$database"))
mkdir("/tmp/backup/sql/$database", 0755);
mysql_select_db($database, $connection);
$tables = mysql_query("SHOW TABLES", $verbinding);
while ($table_row = mysql_fetch_row($tables)) {
$table = $table_row[0];
system("mysqldump -u $user --password=$password --quick --add-drop-table " . escapeshellarg($database) . " " . escapeshellarg($table). " > " . escapeshellarg("/tmp/backup/sql/$database/$table.sql"));
}
}


?>
===========================================================

JP

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to