Skip to content

Instantly share code, notes, and snippets.

@cp6
cp6 / pdo_mysql_backup.php
Last active May 31, 2024 12:41
PHP PDO MySQL backup script with compression
<?php
$backup_config = array(
'DB_HOST' => '127.0.0.1',////Database hostname
'DB_NAME' => 'test_db',//Database name to backup
'DB_USERNAME' => 'root',//Database account username
'DB_PASSWORD' => '',//Database account password
'INCLUDE_DROP_TABLE' => false,//Include DROP TABLE IF EXISTS
'SAVE_DIR' => '',//Folder to save file in
'SAVE_AS' => 'test_db-',//Prepend filename
'APPEND_DATE_FORMAT' => 'Y-m-d-H-i',//Append date to file name