This topic is locked

Making a database backup with a phprunner application

2/5/2023 8:12:30 AM
PHPRunner General questions
I
I author

With phpmyadmin you can make a backup of jr database. But I would like to do that from phprunner. I have made a link from phprunner to a php file that does the backup :

<?php
ob_start();
$username = "XXXX";
$password = "XXXXXX";
$hostname = "localhost";
$dbname = "MY_DATABASE";
// if mysqldump is on the system path you do not need to specify the full path
// simply use "mysqldump --add-drop-table ..." in this case
$command = "mysqldump --add-drop-table --host=$hostname --user=$username ";
if ($password)
$command.= "--password=". $password ." ";
$command.= $dbname;
system($command);
$dump = ob_get_contents();
ob_end_clean();
// send dump file to the output
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($dbname . "_" . date("Y-m-d_H-i-s").".sql"));
flush();
echo $dump;
exit();
?>

This script works great locally, but unfortunately not on the hosting server. Is there another possibility to generate a backup of the (MySql) database with a phprunner application?

A
alghanim 2/6/2023

try this
link

admin 2/7/2023

I suspect that on the server you need to specify a full path to mysqldump executable.

fhumanes 2/7/2023

Hello,

Read this article. https://asprunner.com/forums/topic/29664-Guide-50--Online-Database-Backup

Explain how it can be done and how secillo it is.

Greetings,
fernando

I
I author 2/9/2023

Thank Ferando for you for the helpful information, I have a few questions:
Can you use this example to make a backup of a database that is hosted by a hoster, while your application is located locally on your laptop?
Does the file "index.php" have to be put online, or can this also be stored locally on your laptop?
how should this be added:
$host = 'localhost' or $host = 'http://mysite.com' ???
Thank you

fhumanes 2/9/2023

Hello,

In the example that I have facilitated uses the same connection to the database that has been specified in the PHPRUNNER application, always using the connection of an MySQL client.

I understood that this was the requirement you had.

However, you can study and solve other architectures, but to study a particular case, I prefer that you write to my email Fernandohumanes@gmail.com

Greetings,
fernando