Migrate S3 Buckets with AWS CLI

Data Migration Between S3 Buckets Using AWS CLI

Data Migration Between S3 Buckets Using AWS CLI

How to Transfer Data Between S3 Buckets with AWS CLI

Tasks

  • Create a new private S3 bucket named xfusion-sync-9739.

  • Migrate all data from the existing xfusion-s3-29917 bucket to the new xfusion-sync-9739 bucket.

  • Ensure data consistency between both buckets.

  • Use the AWS CLI for creating the bucket and migrating the data.

Steps

  1. Ensure that we have aws cli configured with credentials.

     aws configure
     ~ on ☁️  (us-east-1) ➜  aws configure
     AWS Access Key ID [****************KG6C]: 
     AWS Secret Access Key [****************LyeE]: 
     Default region name [us-east-1]: 
     Default output format [None]: 
    
     ~ on ☁️  (us-east-1) ➜
  2. Time to create a new private S3 bucket named xfusion-sync-9739.

     aws s3api create-bucket --bucket xfusion-sync-9739 --region us-east-1
  3. Verify the bucket is created or not.

     aws s3 ls
  4. Migrate Data from the Source Bucket.

     aws s3 sync s3://xfusion-s3-29917 s3://xfusion-sync-9739
  5. Verify Data Consistency

    Compare the total number of objects in both buckets to confirm the data migration was successful.

    • For the source bucket:

        aws s3 ls s3://xfusion-s3-29917 --recursive --summarize | grep "Total Objects"
    • For the destination bucket:

        aws s3 ls s3://xfusion-s3-29917 --recursive --summarize | grep "Total Objects"

      Boom! we have successfully solved the exercise.

      #happylearning #cloud #aws #S3 #awscli