Skip to content

Commit

Permalink
Fix no compression backup failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwang401 committed Oct 12, 2024
1 parent 63ee5f2 commit c780ca0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This file is a running track of new features and fixes to each version of the pa

This project follows [Semantic Versioning](http://semver.org) guidelines.

## v4.2.4

### Changes

- Fixed a bug where initiating a backup with no compression fails. #87

## v4.2.3

### Changes
Expand Down
76 changes: 38 additions & 38 deletions app/Repositories/Proxmox/Server/ProxmoxBackupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Convoy\Repositories\Proxmox\Server;

use Convoy\Enums\Server\BackupCompressionType;
use Convoy\Enums\Server\BackupMode;
use Convoy\Models\Backup;
use Convoy\Models\Server;
use Webmozart\Assert\Assert;
use Convoy\Enums\Server\BackupMode;
use Convoy\Enums\Server\BackupCompressionType;
use Convoy\Repositories\Proxmox\ProxmoxRepository;
use Webmozart\Assert\Assert;

class ProxmoxBackupRepository extends ProxmoxRepository
{
Expand All @@ -16,15 +16,15 @@ public function getBackups()
Assert::isInstanceOf($this->server, Server::class);

$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
])
->get('/api2/json/nodes/{node}/storage/{storage}/content', [
'content' => 'backup',
'vmid' => $this->server->vmid,
])
->json();
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
])
->get('/api2/json/nodes/{node}/storage/{storage}/content', [
'content' => 'backup',
'vmid' => $this->server->vmid,
])
->json();

return $this->getData($response);
}
Expand All @@ -43,16 +43,16 @@ public function backup(BackupMode $mode, BackupCompressionType $compressionType)
}

$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/vzdump', [
'vmid' => $this->server->vmid,
'storage' => $this->node->backup_storage,
'mode' => $parsedMode,
'compress' => $compressionType === BackupCompressionType::NONE ? false : $compressionType->value,
])
->json();
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/vzdump', [
'vmid' => $this->server->vmid,
'storage' => $this->node->backup_storage,
'mode' => $parsedMode,
'compress' => $compressionType === BackupCompressionType::NONE ? (int)false : $compressionType->value,
])
->json();

return $this->getData($response);
}
Expand All @@ -62,15 +62,15 @@ public function restore(Backup $backup)
Assert::isInstanceOf($this->server, Server::class);

$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/qemu', [
'vmid' => $this->server->vmid,
'force' => true,
'archive' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->json();
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/qemu', [
'vmid' => $this->server->vmid,
'force' => true,
'archive' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->json();

return $this->getData($response);
}
Expand All @@ -80,13 +80,13 @@ public function delete(Backup $backup)
Assert::isInstanceOf($this->server, Server::class);

$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
'backup' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->delete('/api2/json/nodes/{node}/storage/{storage}/content/{backup}')
->json();
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
'backup' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->delete('/api2/json/nodes/{node}/storage/{storage}/content/{backup}')
->json();

return $this->getData($response);
}
Expand Down

0 comments on commit c780ca0

Please sign in to comment.