Bader H Al Rayyes
Bader H Al Rayyes

Reputation: 522

MySQL backup doesn't work

I am trying to backup a MySQL database called Reserveboxto a .gzip file. I got this script from a tutorial, and I changed the values according to my values. The problem is when I click submit nothing happens. I do not know where did I go.

<form id="form1" name="form1" method="post" action="backup.php">
    <input type="submit" name="Backup" id="Backup" value="Backup" />
</form>

<p>&nbsp;</p>

<?php
    include ("functions_cp/f_connection.php");
    Sqlconnection();

    $dbname = "Reservebox";
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "123";

    function backup() {
        $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
        $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
        system($command);
    }
    if(isset($_POST['backup'])) {
        backup();
    }

Upvotes: 0

Views: 177

Answers (2)

aleroot
aleroot

Reputation: 72686

Try removing the space between the -p and $dbpass.

Also, remove --opt. That is not strictly necessary.

Upvotes: 1

jon
jon

Reputation: 6246

if(isset($_POST['backup'])) { I think the backup on this line needs a capital B!

If that doesn't sort it, try adding error_reporting(E_ALL); on a new line after <?php.

Upvotes: 1

Related Questions