Na localhostu mi funguje script zaloha.php:
<?php
$db_connection = mysql_connect("localhost", "user", "passwd");
if (!$db_connection){
echo "Nepodařilo se připojit k databázi.<BR>";
die();
}
mysql_select_db("db_kterou_chci_zalohovat");
$query = "show tables";
$query_result = mysql_query ($query, $db_connection);
while ($row = mysql_fetch_array ($query_result)) {
$filename = "./zaloha/$row[0]_" . time() . ".txt.gz";
$fp = gzopen ($filename, 'w9');
$query1 = "select * from $row[0]";
$query_result1 = mysql_query ($query1, $db_connection);
while ($row1 = mysql_fetch_row ($query_result1)) {
foreach ($row1 as $key => $value) {
gzwrite ($fp, "'$value'\t");
}
gzwrite ($fp, "\n");
}
gzclose ($fp);
echo "Tabulka $row[0] byla zalohovana. <br></br>\n";
}
?>
V CRONu mam vlozen radek:
0 21 * * * lynx --dump http://localhost/cesta/k/zaloha.php
Tedy kazdy den v 21:00 se v adresari zaloha vytvori pro kazdou tabulku z databaze db_kterou_chci_zalohovat soubor s daty ktere obsahuje.
A konecne k dotazu: Muzu nejak to same udelat na wz?