Skip to content

Latest commit

 

History

History
121 lines (98 loc) · 4.67 KB

backup-agent.md

File metadata and controls

121 lines (98 loc) · 4.67 KB

Table of Contents

  1. Open Service Broker Framework (by evoila)
  2. Components
  3. Configuring a Service Broker
  4. Service Keys
  5. Backup Agent
  6. Development
  7. Local Deployment
  8. Open Service Broker API Features
  9. IDE & Runtime
  10. Contribution
  11. License

Backup Agent

The Backup Manager is a component provided with the evoila OSB Framework in the Enterprise Package. It enables to schedule automatic backups of any endpoint. That means,each endpoint that has a concrete implementation in the osb-backup-manager enables customers/developers to do automatic backups of their Service Instances.

Configuration in the Service Definition

To enable the Backup Connector configuration wise, the Service Broker needs to be deployed with the following settings:

backup:
  enabled: true
catalog:
  services:
    plans:
      - name: xs
        ...
        metadata:
          backup:
            enabled: true
            instance_group: postgres
  • enabled: if set to true it is enabled for the specific plan.
  • instance_group: the instance group the osb-backup-manager is connection to, to execute the backups.

Note: please be aware, that the communication to schedule the backup jobs is done via RabbitMQ. That means, an existing RabbitMQ configuration must exist. Refer to Basic Service Broker configuration for that.

Configuration in the BoshPlatformService

To set the backup functionality for the instance group, configured in the metadata of a plan, use the method

protected ServerAddress toServerAddress(Vm vm, int port, Plan plan)

Example:

@Service
@ConditionalOnBean(BoshProperties.class)
public class MyBoshPlatformService extends BoshPlatformService {

    @Override
    protected void updateHosts(ServiceInstance serviceInstance, Plan plan, Deployment deployment) {
        List<Vm> vms = super.getVms(serviceInstance);
        if (serviceInstance.getHosts() == null)
            serviceInstance.setHosts(new ArrayList<>());
        serviceInstance.getHosts().clear();

        vms.forEach(vm -> serviceInstance.getHosts().add(super.toServerAddress(vm, 1234, plan)));
    }
}

Implementation of the Backup Connector

The Backup Connector is a component

@Service
@ConditionalOnBean(BackupTypeConfiguration.class)
public class BackupCustomServiceImpl implements BackupCustomService {

    BackupTypeConfiguration backupTypeConfiguration;

    ServiceInstanceRepository serviceInstanceRepository;

    PostgresCustomImplementation postgresCustomImplementation;

    ServiceDefinitionRepository serviceDefinitionRepository;

    public BackupCustomServiceImpl(BackupTypeConfiguration backupTypeConfiguration,
                                   ServiceInstanceRepository serviceInstanceRepository,
                                   PostgresCustomImplementation postgresCustomImplementation,
                                   ServiceDefinitionRepository serviceDefinitionRepository) {
        this.backupTypeConfiguration = backupTypeConfiguration;
        this.serviceInstanceRepository = serviceInstanceRepository;
        this.postgresCustomImplementation = postgresCustomImplementation;
        this.serviceDefinitionRepository = serviceDefinitionRepository;
    }

    @Override
    public Map<String, String> getItems(String serviceInstanceId) throws ServiceInstanceDoesNotExistException,
            ServiceDefinitionDoesNotExistException {
        ServiceInstance instance = this.validateServiceInstanceId(serviceInstanceId);

        Plan plan = serviceDefinitionRepository.getPlan(instance.getPlanId());

        PostgresDbService postgresDbService = postgresCustomImplementation.connection(instance, plan);

        Map<String, String> result = new HashMap<>();
        try {
            Map<String, String> databases = postgresDbService.executeSelect("SELECT datname FROM pg_database", "datname");

            for(Map.Entry<String, String> database : databases.entrySet())
                result.put(database.getValue(), database.getValue());
        } catch(SQLException ex) {
            new ServiceBrokerException("Could not load databases", ex);
        }

        return result;
    }
}

<- Previous   |   Next ->