This is an automated email from the ASF dual-hosted git repository.
shwstppr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new d3ec27dc79 Fixed Veeam listing restore points (#6555)
d3ec27dc79 is described below
commit d3ec27dc7904362c0e098db7e3ca838e8afb0281
Author: Harikrishna <[email protected]>
AuthorDate: Wed Aug 10 16:59:10 2022 +0530
Fixed Veeam listing restore points (#6555)
Fixes issue #6465 where listing backup restore points are failing with
Veeam version v11.0.1.1261.
Though this version is not fully supported for backup and recovery,
existing backups, restore points for the VMs can continue to work with the
Veeam version v11.0.1.1261. I've created a separate ticket here to fully
support the version #6554
---
.../cloudstack/backup/VeeamBackupProvider.java | 78 ++++++++++++----------
1 file changed, 42 insertions(+), 36 deletions(-)
diff --git
a/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/VeeamBackupProvider.java
b/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/VeeamBackupProvider.java
index 072431c4a9..ca61148782 100644
---
a/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/VeeamBackupProvider.java
+++
b/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/VeeamBackupProvider.java
@@ -249,6 +249,23 @@ public class VeeamBackupProvider extends AdapterBase
implements BackupProvider,
return getClient(vm.getDataCenterId()).listRestorePoints(backupName,
vm.getInstanceName());
}
+ private Backup
checkAndUpdateIfBackupEntryExistsForRestorePoint(List<Backup> backupsInDb,
Backup.RestorePoint restorePoint, Backup.Metric metric) {
+ for (final Backup backup : backupsInDb) {
+ if (restorePoint.getId().equals(backup.getExternalId())) {
+ if (metric != null) {
+ LOG.debug(String.format("Update backup with [uuid: %s,
external id: %s] from [size: %s, protected size: %s] to [size: %s, protected
size: %s].",
+ backup.getUuid(), backup.getExternalId(),
backup.getSize(), backup.getProtectedSize(), metric.getBackupSize(),
metric.getDataSize()));
+
+ ((BackupVO) backup).setSize(metric.getBackupSize());
+ ((BackupVO) backup).setProtectedSize(metric.getDataSize());
+ backupDao.update(backup.getId(), ((BackupVO) backup));
+ }
+ return backup;
+ }
+ }
+ return null;
+ }
+
@Override
public void syncBackups(VirtualMachine vm, Backup.Metric metric) {
List<Backup.RestorePoint> restorePoints = listRestorePoints(vm);
@@ -262,44 +279,33 @@ public class VeeamBackupProvider extends AdapterBase
implements BackupProvider,
final List<Backup> backupsInDb = backupDao.listByVmId(null,
vm.getId());
final List<Long> removeList =
backupsInDb.stream().map(InternalIdentity::getId).collect(Collectors.toList());
for (final Backup.RestorePoint restorePoint : restorePoints) {
- boolean backupExists = false;
- for (final Backup backup : backupsInDb) {
- if
(restorePoint.getId().equals(backup.getExternalId())) {
- backupExists = true;
- removeList.remove(backup.getId());
- if (metric != null) {
- LOG.debug(String.format("Update backup with
[uuid: %s, external id: %s] from [size: %s, protected size: %s] to [size: %s,
protected size: %s].",
- backup.getUuid(),
backup.getExternalId(), backup.getSize(), backup.getProtectedSize(),
metric.getBackupSize(), metric.getDataSize()));
-
- ((BackupVO)
backup).setSize(metric.getBackupSize());
- ((BackupVO)
backup).setProtectedSize(metric.getDataSize());
- backupDao.update(backup.getId(), ((BackupVO)
backup));
- }
- break;
+ if (!(restorePoint.getId() == null ||
restorePoint.getType() == null || restorePoint.getCreated() == null)) {
+ Backup existingBackupEntry =
checkAndUpdateIfBackupEntryExistsForRestorePoint(backupsInDb, restorePoint,
metric);
+ if (existingBackupEntry != null) {
+ removeList.remove(existingBackupEntry.getId());
+ continue;
}
+
+ BackupVO backup = new BackupVO();
+ backup.setVmId(vm.getId());
+ backup.setExternalId(restorePoint.getId());
+ backup.setType(restorePoint.getType());
+ backup.setDate(restorePoint.getCreated());
+ backup.setStatus(Backup.Status.BackedUp);
+ if (metric != null) {
+ backup.setSize(metric.getBackupSize());
+ backup.setProtectedSize(metric.getDataSize());
+ }
+ backup.setBackupOfferingId(vm.getBackupOfferingId());
+ backup.setAccountId(vm.getAccountId());
+ backup.setDomainId(vm.getDomainId());
+ backup.setZoneId(vm.getDataCenterId());
+
+ LOG.debug(String.format("Creating a new entry in
backups: [uuid: %s, vm_id: %s, external_id: %s, type: %s, date: %s,
backup_offering_id: %s, account_id: %s, "
+ + "domain_id: %s, zone_id: %s].",
backup.getUuid(), backup.getVmId(), backup.getExternalId(), backup.getType(),
backup.getDate(),
+ backup.getBackupOfferingId(),
backup.getAccountId(), backup.getDomainId(), backup.getZoneId()));
+ backupDao.persist(backup);
}
- if (backupExists) {
- continue;
- }
- BackupVO backup = new BackupVO();
- backup.setVmId(vm.getId());
- backup.setExternalId(restorePoint.getId());
- backup.setType(restorePoint.getType());
- backup.setDate(restorePoint.getCreated());
- backup.setStatus(Backup.Status.BackedUp);
- if (metric != null) {
- backup.setSize(metric.getBackupSize());
- backup.setProtectedSize(metric.getDataSize());
- }
- backup.setBackupOfferingId(vm.getBackupOfferingId());
- backup.setAccountId(vm.getAccountId());
- backup.setDomainId(vm.getDomainId());
- backup.setZoneId(vm.getDataCenterId());
-
- LOG.debug(String.format("Creating a new entry in backups:
[uuid: %s, vm_id: %s, external_id: %s, type: %s, date: %s, backup_offering_id:
%s, account_id: %s, "
- + "domain_id: %s, zone_id: %s].",
backup.getUuid(), backup.getVmId(), backup.getExternalId(), backup.getType(),
backup.getDate(),
- backup.getBackupOfferingId(),
backup.getAccountId(), backup.getDomainId(), backup.getZoneId()));
- backupDao.persist(backup);
}
for (final Long backupIdToRemove : removeList) {
LOG.warn(String.format("Removing backup with ID: [%s].",
backupIdToRemove));