function getDbConn() { $endpoint = getDbHost(); //print "</p>============</p>EndPoint: ". $endpoint . "</p>================</p>"; $link = mysqli_connect($endpoint, "controller", "ilovebunnies", "customerrecords") or die("Error " . mysqli_connect_error($link)); return $link; }
// ******************************** $alldb = array(); $GLOBALS['con'] = getDbConn(); $res = mysqli_query($GLOBALS['con'], "SHOW DATABASES;"); while ($row = mysqli_fetch_array($res)) { if ($row['Database'] != "information_schema") { $alldb[] = $row['Database']; deb("Database found: {$row['Database']}"); } } // ******************************** // MySQLDump each database // ******************************** system("mkdir /tmp/{$now}/"); foreach ($alldb as $db) { $cmd = "mysqldump {$db} -h " . getDbHost() . " -u controller -pilovebunnies > /tmp/{$now}/{$db}.sql"; deb("Doing: {$cmd}"); system($cmd); } // ******************************** // gzip databases // ******************************** foreach ($alldb as $db) { system("gzip /tmp/{$now}/{$db}.sql"); } // ******************************** // Upload the files to S3 // ******************************** $s3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-east-1']); $bucket = strtolower('phpmys3backup' . '-' . $now); deb("Creating Bucket {$bucket}");
// ******************************** $alldb = array(); $GLOBALS['con'] = getDbConn(); $res = mysqli_query($GLOBALS['con'], "SHOW DATABASES;"); while ($row = mysqli_fetch_array($res)) { if ($row['Database'] != "information_schema") { $alldb[] = $row['Database']; deb("Database found: {$row['Database']}"); } } // ******************************** // MySQLDump each database // ******************************** system("mkdir /tmp/{$now}/"); foreach ($alldb as $db) { $cmd = "mysqldump {$db} -h " . getDbHost() . " -u controller -panvi2416 > /tmp/{$now}/{$db}.sql"; deb("Doing: {$cmd}"); system($cmd); } // ******************************** // gzip databases // ******************************** foreach ($alldb as $db) { system("gzip /tmp/{$now}/{$db}.sql"); } // ******************************** // Upload the files to S3 // ******************************** $s3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-east-1']); $bucket = strtolower('phpmys3backup' . '-' . $now); deb("Creating Bucket {$bucket}");