Created
June 23, 2016 20:25
-
-
Save d9k/a9620d763c1490d072247141d12a6673 to your computer and use it in GitHub Desktop.
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
#!env php | |
<?php | |
//script is intended to run from site directory | |
//tested on Joomla 2.5 | |
$currentDir = getcwd(); | |
echo "Running from \"${currentDir}\"\n"; | |
$configPath = $currentDir.'/configuration.php'; | |
$backupFolderPath = $currentDir.'/.backupdb'; | |
$backupPath = $backupFolderPath.'/backup.sql'; | |
if (!file_exists($configPath)){ | |
echo "\"${configPath}\" doesn't exist\n"; | |
exit; | |
} | |
if (!is_readable($configPath)){ | |
echo "Access to \"${configPath}\" denied\n"; | |
exit; | |
} | |
include_once $configPath; | |
$config = new JConfig(); | |
$db = $config->db; | |
$password = $config->password; | |
$user = $config->user; | |
$host = $config->host; | |
mkdir($backupFolderPath); | |
echo shell_exec("mysqldump -u${user} -p${password} --single-transaction --hex-blob ${db} --result-file=${backupPath}"); | |
echo shell_exec("ls -lh ${backupFolderPath}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment