HM\BackUpWordPress\Mysqldump_Database_Backup_Engine::backup PHP Метод

backup() публичный Метод

Perform the database backup.
public backup ( ) : boolean
Результат boolean Whether the backup completed successfully or not.
    public function backup()
    {
        if (!$this->get_mysqldump_executable_path()) {
            return false;
        }
        // Grab the database connections args
        $args = $this->get_mysql_connection_args();
        // Allow lock-tables to be overridden
        if (defined('HMBKP_MYSQLDUMP_SINGLE_TRANSACTION') && HMBKP_MYSQLDUMP_SINGLE_TRANSACTION) {
            $args[] = '--single-transaction';
        }
        // Make sure binary data is exported properly
        $args[] = '--hex-blob';
        // The file we're saving too
        $args[] = '-r ' . escapeshellarg($this->get_backup_filepath());
        // The database we're dumping
        $args[] = escapeshellarg($this->get_name());
        $process = new Process($this->get_mysqldump_executable_path() . ' ' . implode(' ', $args));
        $process->setTimeout(HOUR_IN_SECONDS);
        try {
            $process->run();
        } catch (\Exception $e) {
            $this->error(__CLASS__, $e->getMessage());
        }
        if (!$process->isSuccessful()) {
            $this->error(__CLASS__, $process->getErrorOutput());
        }
        return $this->verify_backup();
    }