1<?php
2
3ini_set('display_errors', 1);
4ini_set('display_startup_errors', 1);
5error_reporting(E_ALL);
6
7$database = 'db';
8$user = 'user';
9$pass = 'pass';
10$host = 'localhost';
11$dir = dirname(__FILE__) . '/dump.sql';
12
13echo "<h3>Backing up database to `<code>{$dir}</code>`</h3>";
14
15exec("mysqldump --user={$user} --password={$pass} --host={$host} {$database} --result-file={$dir} 2>&1", $output);
16
17var_dump($output);
1<?php
2 $dbhost = 'localhost:3036';
3 $dbuser = 'root';
4 $dbpass = 'rootpassword';
5
6 $backup_file = $dbname . date("Y-m-d-H-i-s") . '.gz';
7 $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass ". "test_db | gzip > $backup_file";
8
9 system($command);
10?>