Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!env php
  2. <?php
  3. //script is intended to run from site directory
  4. //tested on Joomla 2.5
  5. $currentDir = getcwd();
  6. echo "Running from \"${currentDir}\"\n";
  7.  
  8. $configPath = $currentDir.'/configuration.php';
  9. $backupFolderPath = $currentDir.'/.backupdb';
  10. $backupPath = $backupFolderPath.'/backup.sql';
  11.  
  12. if (!file_exists($configPath)){
  13. echo "\"${configPath}\" doesn't exist\n";
  14. exit;
  15. }
  16.  
  17. if (!is_readable($configPath)){
  18. echo "Access to \"${configPath}\" denied\n";
  19. exit;
  20. }
  21.  
  22. include_once $configPath;
  23.  
  24. $config = new JConfig();
  25.  
  26. $db = $config->db;
  27. $password = $config->password;
  28. $user = $config->user;
  29. $host = $config->host;
  30.  
  31. mkdir($backupFolderPath);
  32. echo shell_exec("mysqldump -u${user} -p${password} --single-transaction --hex-blob ${db} --result-file=${backupPath}");
  33.  
  34. echo shell_exec("ls -lh ${backupFolderPath}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement