How to Migrate S3 Buckets Between AWS Accounts in 5 Minutes
Moving to a new AWS account? Here's how to migrate your S3 bucket data without losing a single file. Simple, fast, and free.
Table of Contents
How to Migrate S3 Buckets Between AWS Accounts in 5 Minutes
Switching AWS accounts? Need to move your S3 data?
It's simpler than you think. No special tools needed — just the AWS CLI.
When You'd Need This
- Moving from a personal AWS account to a company account
- Consolidating multiple AWS accounts
- Migrating from one region to another
- Creating a backup in a separate account
Prerequisites
- AWS CLI installed (
aws --version) - Access keys for both AWS accounts
- Enough local disk space (if buckets are in different accounts)
Step 1: Configure Both Profiles
# Source account (where data lives now)
aws configure --profile old-account
# Enter: Access Key, Secret Key, Region
# Destination account (where data is going)
aws configure --profile new-account
# Enter: Access Key, Secret Key, Region
Step 2: Download from Source
aws s3 sync s3://source-bucket-name ./s3-backup --profile old-account
This downloads everything locally. For a 1GB bucket, takes about 2-3 minutes on a decent connection.
Step 3: Check What You Downloaded
Before uploading, verify the backup:
# Linux/macOS
du -sh ./s3-backup
# Windows PowerShell
(Get-ChildItem -Recurse ./s3-backup | Measure-Object -Property Length -Sum).Sum / 1MB
Step 4: Upload to Destination
# Upload to staging bucket
aws s3 sync ./s3-backup s3://destination-staging --profile new-account
# Upload to production bucket (if needed)
aws s3 sync ./s3-backup s3://destination-production --profile new-account
Step 5: Verify and Cleanup
Verify file count matches:
# Check source
aws s3 ls s3://source-bucket-name --recursive --summarize --profile old-account
# Check destination
aws s3 ls s3://destination-staging --recursive --summarize --profile new-account
Both should show the same total objects and size. Then cleanup:
# Linux/macOS
rm -rf ./s3-backup
# Windows PowerShell
Remove-Item -Recurse -Force ./s3-backup
Same Account? Even Easier
If both buckets are in the same AWS account, skip the local download:
aws s3 sync s3://source-bucket s3://destination-bucket
Direct copy. No local storage needed.
Pro Tips
Run it on EC2 for speed. If you're moving large buckets, spin up a temporary EC2 instance in the same region as the source bucket. Data transfer within the same region is free and much faster than downloading to your laptop.
Use --delete carefully. Adding --delete to s3 sync removes files in the destination that don't exist in the source. Useful for exact mirrors, dangerous if you're not careful.
Check bucket policies. Your destination bucket needs the right permissions. If assets need to be publicly readable:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
Update your app's config. After migration, update your .env with the new bucket details:
BUCKET_NAME=new-bucket-name
BUCKET_REGION_NAME=us-east-2
BUCKET_ENDPOINT_URL=https://s3.us-east-2.amazonaws.com
AWS_ASSET_URL=https://new-bucket-name.s3.us-east-2.amazonaws.com
Common Mistakes
Forgetting to update asset URLs. Your app might have old S3 URLs hardcoded in the database. Run a find-and-replace on your database if needed.
Wrong IAM permissions. The IAM user needs s3:GetObject and s3:ListBucket on the source, and s3:PutObject on the destination. Or just use AmazonS3FullAccess for the migration and scope it down after.
Not checking region pricing. S3 storage costs vary by region. us-east-2 is one of the cheapest.
Bottom Line
S3 migration is just sync down, sync up. Five minutes of work, zero data loss.
Need help with AWS infrastructure?
We handle cloud migrations and DevOps for teams across Nigeria.
📞 WhatsApp: +234 708 711 0468 📧 info@www.raspibtech.com 📍 Lagos Island
Related:
Need Help with Your Project?
Let's discuss how Raspib Technology can help transform your business
Related Articles
How to Migrate an RDS Database Between AWS Accounts
Moving your PostgreSQL or MySQL database to a new AWS account? Here's the complete snapshot-based migration process, including encrypted snapshots, KMS key sharing, and cleanup to stop charges.
Read more →AWS Spot Instances: Run Your Staging Server for $2/Month
Stop paying $50+/month for staging servers. Here's how to set up a complete staging environment with AWS Spot Instances, auto-deploy via GitHub Actions, and free SSL.
Read more →Laravel 11: What Changed and Why You Should Care
Laravel 11 is out. Slimmer structure, better performance, and features that actually save time. Here's what matters.
Read more →