Search code examples
javaamazon-web-servicesaws-sdkaws-java-sdk

how to copy rds snapshot one region to another region using java api programatically


I am new in amazon web Services. How to copy RDS Snapshot one region to another Region using aws-sdk-api java programmatic.


Solution

  • You need to make sure to create the AmazonRDSClient in a specific region and when you create the CopyDBSnapshotRequest you refer to the snapshot with the full identifier.

    Here some pseudo code to copy from us-east zone to eu_central zone

    AmazonRDSClient rdsClient = new AmazonRDSClient(/*add your credentials and the proper constructor overload*/);
    rdsClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1));
    
    CopyDBSnapshotRequest copySnapshot = new CopyDBSnapshotRequest();
    copySnapshot.setSourceDBSnapshotIdentifier("arn:aws:rds:us-east-1:123456789012:snapshot:mysql-instance1-snapshot-20130805");
    copySnapshot.setTargetDBSnapshotIdentifier("mysql-instance1-snapshot-20130805-copy");
    
    DBSnapshot dbSnapshot = rdsClient.copyDBSnapshot(copySnapshot);
    

    Make sure to review Java API for RDS and Copying a DB Snapshot to Another Region