Last active
June 20, 2022 09:23
-
-
Save fiko/75476eec4b4aacb521730d22b29bc8db to your computer and use it in GitHub Desktop.
How to backup database without mysqldump
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 | |
# https://github.com/ifsnop/mysqldump-php | |
require_once('vendor/autoload.php'); | |
use Ifsnop\Mysqldump as IMysqldump; | |
$host = 'localhost'; | |
$db = 'database_name'; | |
$user = 'db_username'; | |
$pass = 'db_password'; | |
try { | |
$dump = new IMysqldump\Mysqldump('mysql:host=' . $host . ';dbname=' . $db, $user, $pass); | |
$dump->start(getcwd() . '/' . $db . '-' . date('YmdHis') . '.sql'); | |
} catch (\Exception $e) { | |
echo 'mysqldump-php error: ' . $e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment