mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	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
This commit is contained in:
		
							parent
							
								
									4d41b6bc44
								
							
						
					
					
						commit
						d3ec27dc79
					
				| @ -249,6 +249,23 @@ public class VeeamBackupProvider extends AdapterBase implements BackupProvider, | |||||||
|         return getClient(vm.getDataCenterId()).listRestorePoints(backupName, vm.getInstanceName()); |         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 |     @Override | ||||||
|     public void syncBackups(VirtualMachine vm, Backup.Metric metric) { |     public void syncBackups(VirtualMachine vm, Backup.Metric metric) { | ||||||
|         List<Backup.RestorePoint> restorePoints = listRestorePoints(vm); |         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<Backup> backupsInDb = backupDao.listByVmId(null, vm.getId()); | ||||||
|                 final List<Long> removeList = backupsInDb.stream().map(InternalIdentity::getId).collect(Collectors.toList()); |                 final List<Long> removeList = backupsInDb.stream().map(InternalIdentity::getId).collect(Collectors.toList()); | ||||||
|                 for (final Backup.RestorePoint restorePoint : restorePoints) { |                 for (final Backup.RestorePoint restorePoint : restorePoints) { | ||||||
|                     boolean backupExists = false; |                     if (!(restorePoint.getId() == null || restorePoint.getType() == null || restorePoint.getCreated() == null)) { | ||||||
|                     for (final Backup backup : backupsInDb) { |                         Backup existingBackupEntry = checkAndUpdateIfBackupEntryExistsForRestorePoint(backupsInDb, restorePoint, metric); | ||||||
|                         if (restorePoint.getId().equals(backup.getExternalId())) { |                         if (existingBackupEntry != null) { | ||||||
|                             backupExists = true; |                             removeList.remove(existingBackupEntry.getId()); | ||||||
|                             removeList.remove(backup.getId()); |                             continue; | ||||||
|                             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 (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, " |                         BackupVO backup = new BackupVO(); | ||||||
|                             + "domain_id: %s, zone_id: %s].", backup.getUuid(), backup.getVmId(), backup.getExternalId(), backup.getType(), backup.getDate(), |                         backup.setVmId(vm.getId()); | ||||||
|                             backup.getBackupOfferingId(), backup.getAccountId(), backup.getDomainId(), backup.getZoneId())); |                         backup.setExternalId(restorePoint.getId()); | ||||||
|                     backupDao.persist(backup); |                         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) { |                 for (final Long backupIdToRemove : removeList) { | ||||||
|                     LOG.warn(String.format("Removing backup with ID: [%s].", backupIdToRemove)); |                     LOG.warn(String.format("Removing backup with ID: [%s].", backupIdToRemove)); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user