I'm trying to use mysqldump from php.
Here is the php im using for this:
$dbhost, $dbuser, $dbpass are present, but not show for security reasons.
Is my actual mysqldump statement correct? I'm really new to linux. The dedicated server we rent uses ubuntu if that helps.
$path = "/home/a/c/acornmedia/public_html/tools/sqlmagic/backup/";
$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $path . $backupFile";
I'm not sure about the $path section, the person that commented on a different post wasn't clear whether this was the path to where the db should be moved to once gzipped, or where the db where it is dumped before its gzipped.
I basically want it to move the final .gz which contains the database dump to /home/a/c/acornmedia/public_html/tools/sqlmagic/backup/ which is the root path to the web area of the server.
However it doesn't work. No files get created in sqlmagic/backup/
Can anyone help?
I'm not a php guy, but maybe it has to do with the permissions of the script. Also, it might be the permissions of your user account on the server.
Try removing the space between the -p and the password variable - this is probably the reason... LEt me know how you get on :-)
yeah the problem was something to do with the password, as it was trying to use the variable for password as the database name,
I've ended up using --password=$dbpass
works fine now!
Thanks for the help.