BackupVmJob.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace ModulesGarden\ProxmoxAddon\App\Jobs\Cloud\Reinstall;
  3. use ModulesGarden\ProxmoxAddon\App\Jobs\BaseJob;
  4. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  5. use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;
  6. class BackupVmJob extends BaseJob
  7. {
  8. use ProductService;
  9. protected function initServices()
  10. {
  11. }
  12. public function handle($text = null)
  13. {
  14. $this->initParams();
  15. $this->initServices();
  16. $this->initVm();
  17. if ($this->isDone())
  18. {
  19. return true;
  20. }
  21. elseif ($this->isTaskRunning())
  22. {
  23. $this->sleep(20);
  24. return false;
  25. }
  26. $storage = $this->configuration()->getBackupStorage() ? $this->configuration()->getBackupStorage() : 'local';
  27. $routing = $this->configuration()->isBackupRouting() == "Yes" ? "1" : "0";
  28. //backup
  29. $taskId = sl('Vm')->getVm()->backup($storage, $routing);
  30. //save task id
  31. $this->putModelDataAndSave(["taskId" => $taskId, "node" => sl('Vm')->getVm()->getNode()]);
  32. $this->sleep(20);
  33. return false;
  34. }
  35. }