public function _action_tasks_fail(FW_Ext_Backups_Task_Collection $collection)
 {
     $error = __('Error', 'fw');
     foreach ($collection->get_tasks() as $task) {
         if ($task->result_is_fail()) {
             if (is_wp_error($task->get_result())) {
                 $error = $task->get_result()->get_error_message();
             }
             break;
         }
     }
     $this->set_active_demo(array('result' => $error));
 }
 /**
  * @param bool $full
  * @param string $zip_path
  * @param array $filesystem_args {}|{hostname: '', username: '', password: '', connection_type: ''}
  */
 public function do_restore($full = false, $zip_path, $filesystem_args = array())
 {
     $full = (bool) $full;
     $tmp_dir = self::backups()->get_tmp_dir();
     $dirs = $this->get_dirs($full);
     $id_prefix = 'restore:';
     $collection = new FW_Ext_Backups_Task_Collection('restore');
     $collection->add_task(new FW_Ext_Backups_Task($id_prefix . 'tmp-dir-clean:before', 'dir-clean', array('dir' => $tmp_dir)));
     $collection->add_task(new FW_Ext_Backups_Task($id_prefix . 'unzip', 'unzip', array('zip' => $zip_path, 'dir' => $tmp_dir)));
     $collection->add_task(new FW_Ext_Backups_Task($id_prefix . 'files-restore', 'files-restore', array('source_dir' => $tmp_dir . '/f', 'destinations' => $dirs, 'filesystem_args' => $filesystem_args)));
     $collection->add_task(new FW_Ext_Backups_Task($id_prefix . 'db-restore', 'db-restore', array('dir' => $tmp_dir, 'full' => $full)));
     if (!$full) {
         $collection->add_task(new FW_Ext_Backups_Task($id_prefix . 'image-sizes-restore', 'image-sizes-restore', array()));
     }
     $collection->add_task(new FW_Ext_Backups_Task($id_prefix . 'tmp-dir-clean:after', 'dir-clean', array('dir' => $tmp_dir)));
     $this->execute_task_collection($collection);
 }
Exemplo n.º 3
0
 /**
  * @param FW_Ext_Backups_Task_Collection $tasks
  * @internal
  */
 public function _action_tasks_success(FW_Ext_Backups_Task_Collection $tasks)
 {
     $this->add_log('success', $tasks->get_title());
 }
 /**
  * @param bool $full
  * @param string $zip_path
  * @param array $filesystem_args {}|{hostname: '', username: '', password: '', connection_type: ''}
  */
 public function do_restore($full = false, $zip_path, $filesystem_args = array())
 {
     $tmp_dir = self::backups()->get_tmp_dir();
     $id_prefix = 'restore:';
     $collection = new FW_Ext_Backups_Task_Collection(($full ? 'full' : 'content') . '-restore');
     $collection->add_task(new FW_Ext_Backups_Task($id_prefix . 'tmp-dir-clean:before', 'dir-clean', array('dir' => $tmp_dir)));
     $this->execute_task_collection($this->add_restore_tasks($collection, $full, $zip_path, $filesystem_args));
 }