Guest User

Untitled

a guest
Oct 19th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. // Database Creds
  4. $DB_NAME = "<database goes here>";
  5. $DB_USER = "<username goes here>";
  6. $DB_PASS = "<password goes here>";
  7. $DB_HOST = "localhost";
  8.  
  9. // Get list of tables
  10. $get_tables = "mysql "
  11. . "--host " . $DB_HOST
  12. . " -p'" . $DB_PASS . "'"
  13. . " -u " . $DB_USER
  14. . " " . $DB_NAME
  15. . " -rse " . "'SHOW TABLES;'";
  16. $tables_str = shell_exec($get_tables);
  17. $tables = preg_split('/\s+/', $tables_str);
  18.  
  19. // Export Database
  20. echo '<h2>Exporting database...</h2>';
  21. echo '<h4>Dumping Tables:</h4><ul>';
  22. foreach ($tables as $table) {
  23. echo '<li>' . $table . '</li>';
  24. $dump_table = "mysqldump "
  25. . "--host " . $DB_HOST
  26. . " -p'" . $DB_PASS . "'"
  27. . " -u " . $DB_USER
  28. . " " . $DB_NAME
  29. . " " . $table
  30. . " >> " . $DB_NAME . ".sql";
  31. shell_exec($dump_table);
  32. }
  33. echo '</ul>';
  34.  
  35. ?>
Add Comment
Please, Sign In to add comment