Skip to content

Instantly share code, notes, and snippets.

@felipeelia
Created October 3, 2018 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipeelia/af117ffb9c61d1fb466655758b4293e4 to your computer and use it in GitHub Desktop.
Save felipeelia/af117ffb9c61d1fb466655758b4293e4 to your computer and use it in GitHub Desktop.
Generate a dump from a WordPress website
<?php
include 'wp-config.php';
ini_set( 'display_errors', 1 );
ini_set( 'display_startup_errors', 1 );
error_reporting( E_ALL );
$dir = dirname( __FILE__ ) . '/dump.sql';
echo "<h3>Backing up database to `<code>{$dir}</code>`</h3>";
exec( 'mysqldump --user=' . DB_USER . ' --password=' . DB_PASSWORD . ' --host=' . DB_HOST . ' ' . DB_NAME . " --result-file={$dir} 2>&1", $output );
var_dump( $output );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment