use of com.emc.storageos.coordinator.client.service.DrUtil in project coprhd-controller by CoprHD.
the class BackupOps method persistBackupInfo.
/**
* Records backup info
*/
private void persistBackupInfo(String backupTag) throws Exception {
File targetDir = new File(getBackupDir(), backupTag);
if (!targetDir.exists() || !targetDir.isDirectory()) {
return;
}
File infoFile = new File(targetDir, backupTag + BackupConstants.BACKUP_INFO_SUFFIX);
Date now = new Date();
try (OutputStream fos = new FileOutputStream(infoFile)) {
Properties properties = new Properties();
properties.setProperty(BackupConstants.BACKUP_INFO_VERSION, getCurrentVersion());
properties.setProperty(BackupConstants.BACKUP_INFO_HOSTS, getHostsWithDualInetAddrs().values().toString());
properties.setProperty(BackupConstants.BACKUP_INFO_CREATE_TIME, Long.toString(now.getTime()));
DrUtil drutil = new DrUtil();
drutil.setCoordinator(coordinatorClient);
String siteId = drutil.getLocalSite().getUuid();
properties.setProperty(BackupConstants.BACKUP_INFO_SITE_ID, siteId);
String siteName = drutil.getLocalSite().getName();
properties.setProperty(BackupConstants.BACKUP_INFO_SITE_NAME, siteName);
properties.store(fos, null);
// Guarantee ower/group owner/permissions of infoFile is consistent with other backup files
FileUtils.chown(infoFile, BackupConstants.STORAGEOS_USER, BackupConstants.STORAGEOS_GROUP);
FileUtils.chmod(infoFile, BackupConstants.BACKUP_FILE_PERMISSION);
} catch (Exception ex) {
log.error("Failed to record backup info", ex);
throw ex;
}
}
Aggregations