Jump to content

mysqldump from php file not populating with data


dlebowski

Recommended Posts

Any help on this would be greatly appreciated.  I am trying to run a mysqldump from my site for my client when they want to back up.  They basically will jsut click a button to run the backup. 

 

With my script below, the backup file is genrated, but there is no table data in the file.  There are the headers in the file with the server IP, linux versin, etc..., but there is no data in the file.  Does this look right?  Thank you for helping me out.

 

Ryan

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

$dbhost = 'localhost';
$dbuser = 'databaseuser';
$dbpass = 'password';

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

$dbname = 'database';
mysql_select_db($dbname);

$tableName  = 'lots';
$backupFile1 = '/home/stuff/wwwroot/stuff/appnew/backup/';
$backupFile = $backupFile1.$dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname | gzip > $backupFile";
system($command);
$result = mysql_query($command);

Link to comment
Share on other sites

I need to take this a step further.  I can actually get it to run using mysqldump, but my DB server is independent of my web server.  I need this file that is created on my DB server in "/home/stuff/wwwroot/stuff/appnew/backup/" to actually be put in a directory on my web server.  How would I do that? 

 

Thank you for the reply.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.