BackupVmJob.php 1.0 KB

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