function pdo_connect() { require_once $_SERVER['DOCUMENT_ROOT'] . '/key/database.php'; $host = get_mysql_host(); $db = get_mysql_database(); $user = get_mysql_user(); $pwd = get_mysql_password(); try { $pdo = new PDO("mysql:host={$host};dbname={$db};charset=utf8", $user, $pwd); return $pdo; } catch (PDOException $e) { var_dump($e->getMessage()); exit; } }
$ini_array = parse_ini_file($file); // Read db_backup.ini into array $FIFO = $ini_array['Fifo']; // Number of archives to save $BACKUP_NAME = $ini_array['Archive_name'] . date('Y-m-d-H-i-s'); //File+time $EXCLUDES = $ini_array['Excludes']; // Assign array to exclude array //=== Mysql connection settings $MYSQL_HOST = 'localhost'; // Default on 3306 $MYSQL_PORT = get_mysql_port(); // Default 3306 User Changeable $MYSQL_USER = '******'; // root user can access all DBs $MYSQL_PASSWD = get_mysql_password(); // Default root User Changeable //=== Set path variables $DB_BASE = "{$base_f}/db_backup"; // Main archive folder $DEST = "{$DB_BASE}/archive"; // Destiation for final archived dbs $log_file = "{$DB_BASE}/log.txt"; // Log file $TEMP = "{$base_f}/tmp/backup_temp"; // Temp location for archive creation //== Check MySQL is running if (!mysql_running()) { // Is MySQL running print " Unable to run backup script \n"; print " MySQL Server not running! \n\n";
function stop_mysql() { // Global variables for paths and files global $usf_uniserv; global $us_mysql_bin; $mysql_password = get_mysql_password(); // Get password $mysql_port = get_mysql_port(); // Get port $cmd1 = "start "; $cmd2 = "{$usf_uniserv} \""; $cmd3 = "{$us_mysql_bin}/mysqladmin.exe --port={$mysql_port} --user=root --password={$mysql_password} shutdown\""; $cmd = $cmd1 . $cmd2 . $cmd3; //print $cmd; // Test code exec($cmd, $dummy, $return); // Run command set_mysql_tracker('free'); // Set tracker free. }