Skip to content

Instantly share code, notes, and snippets.

@jonatw
Created June 8, 2012 09:22
Show Gist options
  • Save jonatw/2894673 to your computer and use it in GitHub Desktop.
Save jonatw/2894673 to your computer and use it in GitHub Desktop.
config file for generate mysqldump
<?php
date_default_timezone_set("Asia/Taipei");
//source DB
$server['host'] = 'hostname_for_source_db';
$server['username'] = 'username_for_source_db';
$server['password'] = 'password_for_soruce_db';
//destination DB
$server_dest['host'] = 'hostname_for_destination_db';
$server_dest['username'] = 'username_for_destination_db';
$server_dest['password'] = 'password_for_destination_db';
//static variables
$static_skip_database = array('information_schema','performance_schema','test','urstylecomtw_backup','mysql');
//init date settings
$date_today = 'latest';
$date_yesterday = date('Y_m_d',strtotime('-1 day'));
//export path
$export_path_prefix = '/tmp/mysql_backup/'.$date_today.'/';
$export_path_yesterday_prefix = '/tmp/mysql_backup/'.$date_yesterday.'/';
//script prefix
$script_prefix = '#!/bin/bash';
// output script path
$script_output_path = '/tmp/mysql_backup_script_'.$date_today.'.sh';
// import script path
$script_import_path = $export_path_prefix.'mysql_import.sh';
// diff script path
$script_diff_path = '/tmp/mysql_diff_script_'.$date_today.'.sh';
// mysql dump prefix
$mysqldump_prefix = 'mysqldump -u'.$server['username'].' -p'.$server['password'].' -h'.$server['host'].' --quick --disable-keys --add-drop-table ';
//mysql import script prefix
$mysql_input_prefix = 'mysql -u'.$server_dest['username'].' -p'.$server_dest['password'].' -h'.$server_dest['host'].' ';
// mysqldump file diff prefix
$diff_prefix = "diff -I 'Dump completed on' -u -h ";
$diff_suffix = ' | wc -l';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment