Hallo ich habe folgendes Problem:
Ich habe mir myphpbackup auf meinem Server isntalliert und möchte ihn über CronJobs backups machen lassen.
Jetzt hat die Export Datei von myphpbackup aber mit ein dropdown feld und ein Submit Button, ich muss also erst die Tabelle auswählen und dann das Abschicken.
Kann man diese beiden schritte irgendwie so automatisieren, das wenn ich die Datei Export.php mit Cronjobs aufrufe direkt Die Tabelle in dem Dropdown steht und er automatisch den submit knopf drückt?
hier mal der Code:
<?php
/************************************************************************/
/* phpMyBakcup */
/* =========== */
/* */
/* Copyright (c) 2002 by Audun Larsen */
/* http://www.phpmybackup.com */
/* */
/* */
/* modified by Martin Norman 27/03/03-- http://www.normsland.co.uk/ */ /* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the QPL License, included in this package. */
/************************************************************************/
include_once("global_conf.php");
include_once("lib/main.lib");
include_once("lib/export.lib");
// set the timelimit
set_time_limit($CONF['time_limit']);
if(isset($argv[1])) {
$mode="shell";
$HTTP_POST_VARS['db']=$argv[1];
$HTTP_POST_VARS['itables']=$argv[2];
$HTTP_POST_VARS['data']="on";
$HTTP_POST_VARS['tables']="on";
} else {
$mode="web";
}
$phpMyBackup=new phpMyBackup;
if($mode=="web") {
$phpMyBackup->printHeader();
}
if(isset($HTTP_POST_VARS['db'])) {
delOldBackups();
$exportLib=new dropTable;
$phpMyBackup->sqlConnect($CONF['sql_host'],$CONF['sql_usr'],$CONF['sql_pass']);
if($mode=="web") {
if($HTTP_POST_VARS['db']=="multiple") {
$db_list=explode(",", $HTTP_POST_VARS['db_list']);
} else {
$db_list[]=$HTTP_POST_VARS['db'];
}
} else {
$db_list=explode(",",$HTTP_POST_VARS['db']);
}
foreach($db_list as $export_db) {
if(!mysql_select_db($export_db,$con)) {
echo"ERROR: Could not select db $export_db<br><br>\n\n";
} else {
$exportLib->dbName=$export_db;
$fileData=$exportLib->structure();
$time=time();
// see if zlib is installed
if (function_exists('gzopen')) {
// open file for writing with maximum compression
$zp = gzopen("./export/".$exportLib->dbName.".".$time.".sql.gz", "wb9");
gzwrite($zp, $fileData);
gzclose($zp);
$BackupFileName=$exportLib->dbName.".".$time.".sql.gz";
$BackupIsGziped=1;
} else {
// write file old fasion way
$fp=fopen("./export/".$exportLib->dbName.".".$time.".sql", "w");
fwrite($fp,$exportLib->structure());
fclose($fp);
$BackupIsGziped=0;
$BackupFileName=$exportLib->dbName.".".$time.".sql";
}
//$fp=fopen("./export/".$exportLib->dbName.".".$time.".sql", "w");
//fwrite($fp,$exportLib->structure());
//fclose($fp);
$backup_size=strlen($fileData);
if(isset($HTTP_POST_VARS['data']) && $HTTP_POST_VARS['data']=="on") {
$store_data="yes";
} else {
$store_data="no";
}
if(isset($HTTP_POST_VARS['tables']) && $HTTP_POST_VARS['tables']=="on") {
$store_tables="yes";
} else {
$store_tables="no";
}
$fp=fopen("./export/".$exportLib->dbName.".".$time.".info", "w");
$comments=str_replace("|","l",$HTTP_POST_VARS['comments']);
fwrite($fp,"$time|$export_db|$backup_size|$store_tables|$store_data|$BackupIsGziped|$comments");
fclose($fp);
chmod("./export/".$BackupFileName,0777);
chmod("./export/".$exportLib->dbName.".".$time.".info",0777);
if($CONF['ftp_use']==1 && function_exists('ftp_connect')) {
$ftp=ftp_store($BackupFileName);
$ftp .= ftp_store($exportLib->dbName.".".$time.".info");
}
if($mode=="web") {
echo"File successfully saved as export/".$BackupFileName."<br>\n<br>\n";
if(isset($ftp)) {
echo $ftp;
}
echo"<br><br>\n\n";
}
}
}
}elseif(!isset($HTTP_POST_VARS['db']) && $mode=="web") {
echo"<form action='export.php' method='post'>\n";
echo"<b>Select database to export:</b> <b>Tables.</B> <small>Enter several seperated by commas(,)</small>.<br>\n";
echo"<select name='db'>\n";
echo"<option value='multiple'>From list</option>";
$phpMyBackup->sqlConnect($CONF['sql_host'],$CONF['sql_usr'],$CONF['sql_pass']);
$db_list = mysql_list_dbs();
while ($row = mysql_fetch_object($db_list)) {
if(@mysql_select_db($row->Database)) {
echo "<option value='".$row->Database . "'>".$row->Database."</option>\n";
}
}
echo"</select>\n";
echo" <input type='text' name='itables'></textarea>\n";
echo"<br>\n";
echo"<b>Or enter several databases seperated with commas(,).</b><br><input type='text' name='db_list'><br>\n";
echo"<br>\n<b>Comments:</b><br>\n";
echo"<textarea name='comments' rows='5' cols='30'></textarea>\n";
echo"<br>\n<input type='checkbox' name='tables' checked><b>Export tables</b>";
echo"<br>\n<input type='checkbox' name='data' checked><b>Export data</b>";
echo"<br>\n<br>\n<input type='submit' value='Export'>\n";
echo"</form>";
}
@mysql_close($con);
if($mode=="web") {
$phpMyBackup->printFooter();
}
?>