Jump to content

Msql backup php script help


sonny

Recommended Posts

Hi I am trying to backup a single complete database using a simple php script I currently use phpMyBackupPro

it works fine but is a little to powerful for what I need.

 

I have tried to implement the following but cannot get it to work, it appears to connect and

it creates the backup .gz file but it contains nothing inside it. can someone please see what I

am doing wrong.

 

<?php

$dbhost = 'testdb.hostedresource.com';
$dbname = 'testname';
$dbuser = 'testuser';
$dbpass = 'MyPassword';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

mysql_select_db($dbname);

$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u$dbuser -p$dbpass $dbname | gzip > $backupFile";
system($command);

mysql_close($conn);

?>

 

Thanks

Sonny

Link to comment
https://forums.phpfreaks.com/topic/186510-msql-backup-php-script-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.