Backup your files using S3 Cross Region Replication (CRR)

Cross-region replication (CRR) enables automatic, asynchronous copying of objects across buckets in different AWS Regions. Buckets configured for cross-region replication can be owned by the same AWS account or by different accounts.s3bucketrep.jpg

Prerequisites of setting up cross-region replication

  • The source and destination buckets must be in different AWS Regions.
  • Both source and destination buckets must have versioning enabled.
  • Amazon S3 must have permissions to replicate objects from the source bucket to the destination bucket on your behalf.

Bucket testcrossregionrep is present in us-east-1 (Northern Virginia) region while bucket crossreplicationbuck2 is present in ap-south-1 (Mumbai) region.
Bucket testcrossregionrep is set up to cross-region replicate to bucket crossreplicationbuck2. Now if you store a file in bucket testcrossregionrep, that file will automatically be copied to the bucket crossreplicationbuck2.

Facts about Cross-region replication

  • Objects that existed before you added the replication configuration to the bucket are not replicated.
  • Amazon S3 creates delete markers for expired objects, but it does not replicate delete markers.
  • We can replicate objects from a source bucket to only one destination bucket. After Amazon S3 replicates an object, the object can’t be replicated again.

S3 Cross Region Replication Lab 

Cross-Regrep.jpg

  1. Create a S3 Bucket in us-east-1 (Northern Virginia) region with name  ‘testcrossregionrep’

crossreg1.jpg

2. Enable versioning for bucket testcrossregionrep

crossreg2

3. Upload two versions of  file helloworld.txt in bucket testcrossregionrep

crossreg3.jpg

4. Click on the Management tab, select Replication and click on the Add Rule button.

crossreg4.jpg

crossreg5.jpg

5. We would like to set the entire bucket as the source so leave the default settings and click Next.

crossreg6.jpg

6. Let us create a new bucket ‘crossreplicationbuck2′ in ap-south-1 (Mumbai) region where we want to replicate.Click on create new bucket option.

crossreg7.jpg

7. Provide the desired bucket name (here: crossreplicationbuck2)  and select the region ( here:Mumbai)

crossreg8.jpg

8. Now we have to grant S3 permissions to replicate objects. Just select Create new role in the IAM role field and give a name to your rule. Make sure enabled is selected and click Next.

crossreg9.jpg

crossreg10.jpg

crossreg11.jpg

9. Review your Replication rule and click Save to enable cross-region replication.

crossreg12.jpg

Now we have setup the cross region replication for S3 and summary is as below.

crossreg13.jpg

Now test the replication by uploading a file to your source bucket. When it’s done uploading, you should see the same file in your destination bucket.

Upload new version of file helloworld.txt in bucket testcrossregionrep

crossreg14.jpg

crossreg15.jpg

Navigate to bucket crossreplicationbuck2 and verify that the object is being replicated.

crossreg16.jpg

For large objects to replicate, it can take several hours. Although it might take a while before a replica is available in the destination bucket, it takes the same amount of time to create the replica as it took to create the corresponding object in the source bucket.

Reference : https://docs.aws.amazon.com/AmazonS3/latest/dev/crr.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: