EasyManuals Logo

Amazon Redshift User Manual

Amazon Redshift
131 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #64 background imageLoading...
Page #64 background image
import com.amazonaws.services.redshift.model.DescribeClusterSnapshotsResult;
import com.amazonaws.services.redshift.model.Snapshot;
public class CreateAndDescribeSnapshot {
public static AmazonRedshiftClient client;
public static String clusterIdentifier = "***provide cluster identifier***";
public static long sleepTime = 10;
public static void main(String[] args) throws IOException {
AWSCredentials credentials = new PropertiesCredentials(
CreateAndDescribeSnapshot.class
.getResourceAsStream("AwsCredentials.properties"));
client = new AmazonRedshiftClient(credentials);
try {
// Unique snapshot identifier
String snapshotId = "my-snapshot-" + (new SimpleDateFormat("yyyy-
MM-dd-HH-mm-ss")).format(new Date());
Date createDate = createManualSnapshot(snapshotId);
waitForSnapshotAvailable(snapshotId);
describeSnapshots();
deleteManualSnapshotsBefore(createDate);
describeSnapshots();
} catch (Exception e) {
System.err.println("Operation failed: " + e.getMessage());
}
}
private static Date createManualSnapshot(String snapshotId) {
CreateClusterSnapshotRequest request = new CreateClusterSnapshotRequest()
.withClusterIdentifier(clusterIdentifier)
.withSnapshotIdentifier(snapshotId);
Snapshot snapshot = client.createClusterSnapshot(request);
System.out.format("Created cluster snapshot: %s\n", snapshotId);
return snapshot.getSnapshotCreateTime();
}
private static void describeSnapshots() {
DescribeClusterSnapshotsRequest request = new DescribeClusterSnapshots
Request()
.withClusterIdentifier(clusterIdentifier);
DescribeClusterSnapshotsResult result = client.describeClusterSnap
shots(request);
printResultSnapshots(result);
}
private static void deleteManualSnapshotsBefore(Date creationDate) {
API Version 2012-12-01
60
Amazon Redshift Management Guide
Managing Snapshots Using AWS SDK for Java

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Amazon Redshift and is the answer not in the manual?

Amazon Redshift Specifications

General IconGeneral
ProviderAmazon Web Services (AWS)
Query LanguageSQL
Data StorageColumnar storage
SecurityEncryption at rest and in transit, VPC, IAM
BackupAutomated and manual snapshots
DeploymentCloud-based
TypeCloud-based data warehouse service
Primary UseData warehousing, analytics
IntegrationIntegrates with AWS services, BI tools, and ETL tools
Pricing ModelOn-demand and reserved instance pricing
Data CompressionColumnar storage with data compression
Performance OptimizationQuery optimization

Related product manuals