Example usage for com.amazonaws.services.rds.model CreateDBSnapshotRequest CreateDBSnapshotRequest

List of usage examples for com.amazonaws.services.rds.model CreateDBSnapshotRequest CreateDBSnapshotRequest

Introduction

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

Prototype

public CreateDBSnapshotRequest() 

Source Link

Document

Default constructor for CreateDBSnapshotRequest object.

Usage

From source file:br.com.objectos.aws.rds.maven.plugin.CreateSnapshotMojo.java

License:Apache License

private void execute0() throws MojoExecutionException {
    AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
    AmazonRDSClient client = new AmazonRDSClient(credentials);

    CreateDBSnapshotRequest createDBSnapshotRequest = new CreateDBSnapshotRequest()
            .withDBInstanceIdentifier(dBInstanceIdentifier).withDBSnapshotIdentifier(dBSnapshotIdentifier);

    info("Starting RDS Snapshot '%s' at '%s'", dBSnapshotIdentifier, dBInstanceIdentifier);
    long startTime = System.currentTimeMillis();

    DBSnapshot snapshot = client.createDBSnapshot(createDBSnapshotRequest);
    info("Backing up... please wait.");

    while (!isDone(snapshot)) {
        try {//  w w  w .  j  av  a 2 s .c o m
            Thread.sleep(5000);
            snapshot = describeSnapshot(client);

            if (snapshot == null) {
                break;
            }
        } catch (InterruptedException e) {
            throw new MojoExecutionException("Interrupted while waiting", e);
        }
    }

    long endTime = System.currentTimeMillis();

    info("Snapshot took %d ms", endTime - startTime);
}