Connecting Tech Pros Worldwide Forums | Help | Site Map

backup using nysqldump

Ben
Guest
 
Posts: n/a
#3: Jun 2 '08

re: backup using nysqldump


Hi at all,

I read this contribute on www.php.net about backup of mysql databases and/or
tables using PHP system function

with this script I tryed to write a custom script to save only one table or
more tables excluding others but my script not work.

my script is:

<?php

// Enter your MySQL access data $host= '00.000.000.'''; $user=
'Sqlmyuserid'; $pass= 'mypassword';

$db= 'Sql00000_nn';

//Tables to save added by me

$table1="rows";

$table2="headers";

$backupdir = 'backups';

// Compute day, month, year, hour and min.

$today = getdate();

$day = $today[mday];

if ($day < 10) {

$day = "0$day";

}

$month = $today[mon];

if ($month < 10) {

$month = "0$month";

}

$year = $today[year];

$hour = $today[hours];

$min = $today[minutes];

$sec = "00";

// Execute mysqldump command.

// It will produce a file named $db-$year$month$day-$hour$min.gz

// under $DOCUMENT_ROOT/$backupdir

system(sprintf(

'mysqldump --opt -h %s -u %s -p%s %s | gzip %s/%s/%s-%s%s%s-%s%s.gz',
$host,

$user,

$pass,

$db $table1 $table2,

getenv('DOCUMENT_ROOT'),

$backupdir,

$db,

$year,

$month,

$day,

$hour,

$min

)); echo '+DONE'; ?>

Please can you tell me how can I do correctly to add the name of tables to
backup?

Best regards and thank you very much



Rik Wasmus
Guest
 
Posts: n/a
#1: Jun 2 '08
On Wed, 16 Apr 2008 08:51:57 +0200, Ben <ben@nospam.itwrote:
Quote:
Hi at all,
>
I read this contribute on www.php.net about backup of mysql databases
and/or
tables using PHP system function
>
with this script I tryed to write a custom script to save only one table
or
more tables excluding others but my script not work.
......
Quote:
system(sprintf(
>
'mysqldump --opt -h %s -u %s -p%s %s | gzip %s/%s/%s-%s%s%s-%s%s.gz',
......
Quote:
Please can you tell me how can I do correctly to add the name of tables
to
backup?
comp.databases.mysql would be better. However: see here:
<http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html#option_mysqldump_tables>
--
Rik Wasmus
Captain Paralytic
Guest
 
Posts: n/a
#2: Jun 2 '08

re: backup using nysqldump


On 16 Apr, 06:51, "Ben" <b...@nospam.itwrote:
Quote:
Hi at all,
>
I read this contribute onwww.php.netabout backup of mysql databases and/or
tables using PHP system function
>
with this script I tryed to write a custom script to save only one table or
more tables excluding others but my script not work.
>
my script is:
>
<?php
>
// Enter your MySQL access data $host= '00.000.000.'''; $user=
'Sqlmyuserid'; $pass= 'mypassword';
>
$db= 'Sql00000_nn';
>
//Tables to save added by me
>
$table1="rows";
>
$table2="headers";
>
$backupdir = 'backups';
>
// Compute day, month, year, hour and min.
>
$today = getdate();
>
$day = $today[mday];
>
if ($day < 10) {
>
$day = "0$day";
>
}
>
$month = $today[mon];
>
if ($month < 10) {
>
$month = "0$month";
>
}
>
$year = $today[year];
>
$hour = $today[hours];
>
$min = $today[minutes];
>
$sec = "00";
>
// Execute mysqldump command.
>
// It will produce a file named $db-$year$month$day-$hour$min.gz
>
// under $DOCUMENT_ROOT/$backupdir
>
system(sprintf(
>
'mysqldump --opt -h %s -u %s -p%s %s | gzip %s/%s/%s-%s%s%s-%s%s.gz',
$host,
>
$user,
>
$pass,
>
$db $table1 $table2,
>
getenv('DOCUMENT_ROOT'),
>
$backupdir,
>
$db,
>
$year,
>
$month,
>
$day,
>
$hour,
>
$min
>
)); echo '+DONE'; ?>
>
Please can you tell me how can I do correctly to add the name of tables to
backup?
>
Best regards and thank you very much
"but my script not work"
Based on the above statement, I can say that there is something wrong.

If you would care to expand on precisely in what way it does not work
and what actually happens when you run it, I will try to expand on my
answer.

Garbage in - Garbage out.
Closed Thread


Similar PHP bytes