Skip to main content

Command Palette

Search for a command to run...

Data Migration Between S3 Buckets Using AWS CLI

How to Transfer Data Between S3 Buckets with AWS CLI

Published
1 min read
Data Migration Between S3 Buckets Using AWS CLI
A

Infosec Poet and CAP-certified DevOps/SecOps Engineer, passionate about security, creativity, and continuous learning.

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

Cloud Platforms

Part 5 of 48

This series covers cloud platforms (AWS, Azure, GCP, OCI), including certifications, labs, issues, solutions, and billing. We'll also explore on-premises solutions and hybrid cloud environments.

Up next

Configuring an EC2 Instance as a Web Server with Nginx

Hosting Websites on EC2: Configure Your Web Server with Nginx