Example usage for com.amazonaws.services.rds.model ModifyDBInstanceRequest withBackupRetentionPeriod

List of usage examples for com.amazonaws.services.rds.model ModifyDBInstanceRequest withBackupRetentionPeriod

Introduction

In this page you can find the example usage for com.amazonaws.services.rds.model ModifyDBInstanceRequest withBackupRetentionPeriod.

Prototype


public ModifyDBInstanceRequest withBackupRetentionPeriod(Integer backupRetentionPeriod) 

Source Link

Document

The number of days to retain automated backups.

Usage

From source file:com.github.blacklocus.rdsecho.EchoModify.java

License:Open Source License

@Override
boolean traverseStage(DBInstance instance) {

    // Prepare request and build up informational message with conditional parts.

    StringWriter proposed = new StringWriter();
    PrintWriter printer = new PrintWriter(proposed);
    printer.format("Proposed db modifications...%n");

    ModifyDBInstanceRequest request = new ModifyDBInstanceRequest();
    request.withDBInstanceIdentifier(instance.getDBInstanceIdentifier());

    Optional<String> dbParameterGroupNameOpt = cfg.modDbParameterGroupName();
    if (dbParameterGroupNameOpt.isPresent()) {
        request.withDBParameterGroupName(dbParameterGroupNameOpt.get());
        printer.format("  db param group name    : %s%n", dbParameterGroupNameOpt.get());
    }/*from  ww w.j av a  2 s .  c om*/
    Optional<String[]> dbSecurityGroupsOpt = cfg.modDbSecurityGroups();
    if (dbSecurityGroupsOpt.isPresent()) {
        request.withDBSecurityGroups(dbSecurityGroupsOpt.get());
        printer.format("  db security groups     : %s%n", Arrays.asList(dbSecurityGroupsOpt.get()));
    }
    Optional<Integer> backupRetentionPeriodOpt = cfg.modBackupRetentionPeriod();
    if (backupRetentionPeriodOpt.isPresent()) {
        request.withBackupRetentionPeriod(backupRetentionPeriodOpt.get());
        printer.format("  backup retention period: %d%n", backupRetentionPeriodOpt.get());
    }
    boolean applyImmediately = cfg.modApplyImmediately();
    printer.format("  apply immediately      : %b%n", applyImmediately);
    request.withApplyImmediately(applyImmediately);

    LOG.info(proposed.toString());

    // Interactive user confirm

    if (cfg.interactive()) {
        String format = "Proceed to modify DB instance with these settings? Input %s to confirm.";
        String dbInstanceId = instance.getDBInstanceIdentifier();
        if (!EchoUtil.prompt(dbInstanceId, format, dbInstanceId)) {
            LOG.info("User declined to proceed. Exiting.");
            return false;
        }
    }

    // Do the deed

    LOG.info("Modifying existing DB instance.");
    rds.modifyDBInstance(request);
    LOG.info("Submitted instance modify request. The instance may need to be rebooted to receive the effect of "
            + "certain settings. See AWS RDS documentation for details:\n"
            + "http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.html#Overview.DBInstance.Modifying");

    return true;
}