Created
September 22, 2016 11:40
-
-
Save statickidz/20467ba858653585fe82d952af536da8 to your computer and use it in GitHub Desktop.
Dump Wordpress database from PHP
This file contains 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 | |
$wpConfig = $_SERVER['DOCUMENT_ROOT'].'/wp-config.php'; | |
if (file_exists($wpConfig)) { | |
header('Content-Description: File Transfer'); | |
header('Content-Type: application/octet-stream'); | |
header('Content-Disposition: attachment; filename='.basename($wpConfig)); | |
header('Expires: 0'); | |
header('Cache-Control: must-revalidate'); | |
header('Pragma: public'); | |
header('Content-Length: ' . filesize($wpConfig)); | |
readfile($wpConfig); | |
exit; | |
} | |
/** | |
* Run this after dumpng wp-config.php, then you can download file with http://yourwebsite.com/dump.sql | |
* exec('mysqldump --user=your_user --password=your_password --host=localhost your_database > dump.sql'); | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment