<?
include('../Code/confHeader.inc');
$Me -> goIfInvalid("../index.php");
$Me -> goIfNotChair('../index.php');
$Conf -> connect();
?>

<html>

<? $Conf->header("Prepare a backup of the $ConfShortName Database") ?>

<body>

<?
if ( IsSet($submitted) ) {
    $time=mktime();
    $dumpname = "$ConfDBDumpDir/$ConfDBName-$time";
    $cmd = "/usr/bin/mysqldump -u $ConfDBUser -p$ConfDBPass "
      . " -h $ConfDBHost $ConfDBName > $dumpname";

    $Conf->infoMsg("Dump command is $cmd");

    $rval = 0;
    $ret = system($cmd,$rval);

    if ( !$rval ) {
      $Conf->infoMsg("The database was dumped to $dumpname. It is "
		     . filesize($dumpname) . " bytes large. You should "
		     . " copy it to another location ");
    } else {
      $Conf->errorMsg("There was an error dumping the database. "
		      . "Try doing it by hand using the mysqldump command ");
    }
} else {
?>

<form METHOD=POST ACTION="<? echo $PHP_SELF ?>" >
<INPUT type=SUBMIT name='submitted' value='Press this button to backup the database'>
</form>

<p> If you do not want to backup the database, return to the task index. </p>

<?}?>

<? $Conf->footer() ?>
</body>
</html>
