backup using nysqldump
am 16.04.2008 08:51:57 von Ben
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:
// 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
Re: backup using nysqldump
am 16.04.2008 11:00:48 von luiheidsgoeroe
On Wed, 16 Apr 2008 08:51:57 +0200, Ben wrote:
> 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.
......
> system(sprintf(
>
> 'mysqldump --opt -h %s -u %s -p%s %s | gzip > %s/%s/%s-%s%s%s-%s%s.gz',
......
> 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:
--
Rik Wasmus
Re: backup using nysqldump
am 16.04.2008 11:06:19 von Captain Paralytic
On 16 Apr, 06:51, "Ben" wrote:
> 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:
>
>
>
> // 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.