// ******************************* Config::enableLogging(); // ******************** // *** Initial output // Task::log("\n---------------------------------------\n"); Task::log("-------- Sync database\n\n"); // Prompt for user password, if it's not hardcoded CliTask::promptAccountPassword($cogecoAccount); // ******************** // Prompt user input // // Prepare a list of possible databases to sync from $dbList = array($localPublicDb, $localPublicUBCDb, $localPublicPromo, $localPublicGBIncrease, $localDevPhoenixDb, $devPublicDb, $dev2PublicDb, $dev3PublicDb, $dev4PublicDb, $uatPublicDb, $preprodPublicDb); // Prompt user to input a source database $sourceDb = CliTask::promptDatabase($dbList, 'Choose a source database:'); Task::log("You chose " . $sourceDb->getDbName() . " on " . $sourceDb->getHost()->getHostname() . "\n\n"); if (($key = array_search($sourceDb, $dbList)) !== false) { unset($dbList[$key]); } // Prepare a list of possible databases to sync to $destinationDb = CliTask::promptDatabase($dbList, 'Choose a destination database:'); Task::log("You chose " . $destinationDb->getDbName() . " on " . $destinationDb->getHost()->getHostname() . "\n\n"); CliTask::promptQuit('Continue? [y/n]: '); // Dump DB to an sql script $tmpDumpFile = new File(SCRIPT_DB_DIR, $sourceDb->getHost()->getHostname() . '-' . $sourceDb->getDbName() . '-' . Config::get('datetime.slug') . '.sql'); MysqlTask::mysqlDump($sourceDb, $sourceDb->getDbName(), array(), $tmpDumpFile); // Import DB from the sql script MysqlTask::importDump($destinationDb, $tmpDumpFile->getPath(), $destinationDb->getDbName()); // Delete the temporary script //unlink($tmpDumpFile->getPath());
Task::log("to {$destinationDbSchema} on {$destinationDb->getHost()->hostname}\n\n"); // $tmpDumpFile = new File(SCRIPT_DIR . '/db', "{$sourceDbSchema}-" . Config::get('datetime.slug') . '.sql'); MysqlTask::mysqlDump($sourceDb, $sourceDbSchema, array(), $tmpDumpFile); // ******************** // *** Prep sync to intermediate remote location // Task::log("- Syncing revision {$workingCopy->info->commitRevision} with {$syncDestinationDir1->getPath()} on {$syncDestinationDir1->getHost()->hostname}\n\n"); // FileSyncTask::sync($rsyncOptions1); // ******************** // *** Deploy // TimerTask::start(); // Import DB MysqlTask::importDump($destinationDb, $tmpDumpFile->getPath(), $destinationDbSchema); // Task::log("- Syncing intermediate directory {$syncDestinationDir1->path} with {$syncDestinationDir2->path}\n\n"); // $rsyncCommand = FileSyncTask::getRsyncCommand($rsyncOptions2); SshTask::exec($syncDestinationDir1->getHost(), $rsyncCommand); // Stop the deploy timer and log it TimerTask::stop(); Task::log("Deploy time: " . TimerTask::getLastElapsedTime() . "\n\n"); exit; // ******************** // *** Tag // if ($build === 'prod') { SvnTask::commit($workingCopy, "Release to Production"); }