Created
April 28, 2017 06:08
-
-
Save gelanivishal/e30285aead87dfbdfa38bb9e092fc6db to your computer and use it in GitHub Desktop.
Magento Database Backup Without phpmyadmin access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL ^ E_NOTICE); | |
ini_set('display_errors', 1); | |
ini_set('memory_limit', '512M'); | |
// Get Magento Application | |
require_once 'app/Mage.php'; | |
Mage::app('default'); | |
// get Magento config | |
$config = Mage::getConfig()->getResourceConnectionConfig("default_setup"); | |
$dbinfo = array( | |
'host' => $config->host, | |
'user' => $config->username, | |
'pass' => $config->password, | |
'dbname' => $config->dbname | |
); | |
// Database Config | |
$db_host = $dbinfo[“host”]; | |
$db_user = $dbinfo[“user”]; | |
$db_pass = $dbinfo[“pass”]; | |
$db_name = $dbinfo[“dbname”]; | |
// filename | |
$backup_file = $db_name ."-". date("Y-m-d-H-i-s") . ".gz"; | |
$command = "mysqldump --database " . $db_name . " -u ". $db_user . " -p'". $db_pass . "' | gzip > " . $backup_file; | |
echo 'command executing is ' . $command . '<br/>' ; | |
$output = shell_exec($command); | |
echo 'Finished!<br/>' ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment