public function createBackups(BackupHandler $handler) { $createdBackupArchives = array(); foreach ($handler->config['directories'] as $name => $backup_paths) { $bpath = $handler->getBackupFilePath($name); $backup_paths = (array) $backup_paths; $cmd = "tar -zcf {$bpath} -P " . implode(' ', $backup_paths); $handler->doExec($cmd); $createdBackupArchives[] = $bpath; } return $createdBackupArchives; }
public function createBackups(BackupHandler $handler) { $createdBackupArchives = array(); $config = $handler->config['database']; // Get databases in array.. $databases = array(); $dbh = new \PDO("mysql:host={$config['host']}", $config['user'], $config['password']); $dbs = $dbh->query('SHOW DATABASES'); while (($db = $dbs->fetchColumn(0)) !== false) { if (!in_array($db, $config['ignore_databases'])) { $databases[] = $db; } } // Run. foreach ($databases as $db) { $bpath = $handler->getBackupFilePath($db); $cmd = "mysqldump --force --opt --user={$config['user']} --password={$config['password']} --databases {$db} | gzip -c > {$bpath}"; $handler->doExec($cmd, false, function ($msg) { return preg_replace("/password=(.*?)--databases/i", 'password="******" --databases', $msg); }); $createdBackupArchives[] = $bpath; } return $createdBackupArchives; }