- How to migrate a live application from AWS EC2 to DigitalOcean? — Overview of steps
- 1. Phase One — Assessment and Preparation
- 2. Designing the target architecture in DigitalOcean
- 3. Transfer files and objects (S3 → Spaces / EBS → Volume)
- 4. Database migration (RDS → Managed DB or self-hosted)
- 5. Application Deployment — Options and Commands
- 6. Network, Security and Cutover Without Downtime
- 7. Operational Tips and Scripts
- 8. Post-migration — Testing and Optimization
- 9. Cost and resource management tips
- 10. Common problems and solutions
- 11. Sample Nginx configuration for Load Balancer and upstream Droplets
- 12. Security tips and compliance with best practices
- Conclusion
- Frequently Asked Questions
How to migrate a live application from AWS EC2 to DigitalOcean? — Overview of steps
In this step-by-step and technical guide, we explain how How to Migrate a Live Application from AWS EC2 to DigitalOcean Transfer with minimal downtime and maintaining security and network considerations.
- Initial assessment and inventory of resources (EC2, EBS, RDS, S3, ELB, Security Groups, IAM)
- Designing the target architecture in DigitalOcean (Droplet, VPC, Volumes, Spaces, Load Balancer, Managed DB)
- Data transfer (files, S3 → Spaces, DB → Managed DB or replica)
- Application deployment (restore, containerization, or using App Platform/Kubernetes)
- Cutover with minimal downtime (replication, floating IP, DNS TTL)
- AWS cleanup and final review, and security measures and monitoring
1. Phase One — Assessment and Preparation
Resource cataloging
Make a complete list of all related resources: EC2 instances, EBS volumes and snapshots, security groups, load balancers, IAM roles/policies, and other dependent services such as S3, RDS, ElastiCache, and CloudFront.
Determine the type of app Required: Is the app stateful (e.g. with a DB), stateless (e.g. frontend), containerized, or requires GPU/rendering?
Determining functional and location needs
Specify parameters such as network latency, GPU requirements, maximum IOPS, and output bandwidth.
If you need low ping for trading or gaming, choose a location close to your end users. DigitalOcean also has different regions—check which DO datacenter is closest.
2. Designing the target architecture in DigitalOcean
Suggested components
The architectural proposal includes the following:
- Droplet For applications and services (VPS)
- Managed Databases (Postgres / MySQL) to eliminate the complexity of replication and backups
- Spaces (S3-compatible) for transferring objects from S3
- Block Storage Volumes For big data and persistence
- Load Balancer and Floating IP For cutover without downtime
- VPC For network isolation and firewall for access control
- Use GPU servers or dedicated compute servers if you need GPUs
Choosing Droplet Size and Type
Use CPU-optimized droplets for CPU-bound apps and high-RAM droplets or managed services for memory-intensive apps.
For trading or gaming, a dedicated VPS with low ping and dedicated network resources in a suitable location is recommended.
3. Transfer files and objects (S3 → Spaces / EBS → Volume)
S3 → Spaces Transfer
To transfer objects from S3 to Spaces, use S3-compatible tools such as rclone Or s3cmd Use.
rclone config
rclone sync s3:my-bucket spaces:my-space --progressYou can also export with aws cli and then upload with doctl or s3cmd.
Server file transfer (EBS → Droplet)
For large volumes and static content from rsync To sync, use:
rsync -azP --delete -e "ssh -i /path/to/key.pem" ubuntu@ec2-ip:/var/www/ /home/ubuntu/www/If you need a snapshot, first take a snapshot from EBS, compress the contents, and then transfer it to the Droplet.
4. Database migration (RDS → Managed DB or self-hosted)
Options based on DB type
MySQL/MariaDB:
For low downtime, set up a replica on DigitalOcean and then perform a switchover. If you are using RDS:
- Create a Managed Database in DO.
- Establish an external replica from RDS or use mysqldump.
mysqldump -u user -p --single-transaction --quick --lock-tables=false dbname > dump.sql
mysql -h do-managed-host -u user -p dbname < dump.sqlPostgreSQL: Logical replication (pg_dump/pg_restore) or streaming replication is recommended for near zero certainty.
pg_dump -Fc -h aws-rds-host -U user dbname > db.dump
pg_restore -d dbname -h do-host -U user db.dumpNo downtime solution (MySQL example)
General process:
- Enable binary logging in AWS.
- Create a MySQL replica server on DigitalOcean and connect it as a slave to the master on AWS.
- After synchronization, push the application to the replica and promote it.
5. Application Deployment — Options and Commands
Method 1 — Containerization and Registry
Containerization with Docker/Kubernetes is the best way to migrate without relying on AMI. Build the image in CI and push to Docker Hub or GitLab Registry.
In DO, you can use Managed Kubernetes or droplets with docker-compose.
docker-compose pull
docker-compose up -d --remove-orphansMethod 2 — Traditional Restore
In the traditional way, you install the packages, transfer the code with rsync, and run the service with systemd or a process manager like PM2.
npm install --production
pm2 start app.js --name myappUsing App Platform and Managed Services
DigitalOcean App Platform can provide CI/CD, autoscaling, and automatic SSL, and is suitable for web apps if you don't want to manage a low-level server.
6. Network, Security and Cutover Without Downtime
Floating IP and Load Balancer
For cutover without downtime, you can set up a Load Balancer in DO and use Floating IP Or use a different target group.
Strategy blue-green It usually includes these steps:
- Setting up a green environment in DO and fully publishing the app
- Health checks
- Changing Floating IP or Changing Target Group in Load Balancer
DNS TTL reduction Don't forget to pre-cutover (e.g. TTL=300s or less) to make propagation faster.
Firewall and security
Add an SSH key to your DO account and disable password login:
Edit /etc/ssh/sshd_config: PermitRootLogin no, PasswordAuthentication noUse UFW for basic access management:
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enableUse cloud firewall in DO and implement rules similar to security groups in AWS. Installation fail2ban And using SSL with Certbot or a certificate managed by Load Balancer is also recommended.
7. Operational Tips and Scripts
doctl Examples
DO CLI installation and authentication:
doctl auth init --access-token <TOKEN>Example of creating a Droplet:
doctl compute droplet create my-droplet --size s-2vcpu-4gb --image ubuntu-22-04-x64 --region nyc3 --ssh-keys <KEY_ID> --vpc-uuid <VPC_ID> --waitdoctl compute cdn create --origin my-space.nyc3.digitaloceanspaces.com ...rsync for incremental sync
rsync -azP --delete -e "ssh -i ~/.ssh/do_key" /var/www/ user@do-ip:/var/www/8. Post-migration — Testing and Optimization
Performance review and monitoring
Inspect logs, latency, and throughput with tools like Prometheus/Grafana or New Relic. Load test with tools like ab or siege and check IOPS and network bandwidth is essential.
Backup and Disaster Recovery
Enable snapshots and automated backups for Droplets and Managed Databases and test the restore plan.
9. Cost and resource management tips
Compare costs between AWS (EC2 + EBS + RDS + S3) and DO combination (Droplets + Volumes + Managed DB + Spaces).
If your app requires a wide network, using a CDN and BGP/Anycast can reduce global latency.
10. Common problems and solutions
- Database version difference → Compatibility testing and migration in staging, using logical dumps.
- Large files and slow transfers → tar+gzip compression, resume with rsync, and use Spaces to deliver content.
- SSL and CORS errors after cutover → Check the certificate chain and Nginx/Load Balancer settings.
11. Sample Nginx configuration for Load Balancer and upstream Droplets
upstream app {
server 10.0.0.5:3000;
server 10.0.0.6:3000;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}12. Security tips and compliance with best practices
- Use of SSH Keys and activation 2FA In cloud accounts
- Restricting IAM access and API keys
- Performing vulnerability scans and patch management
- Enable DDoS protection and WAF if needed
Conclusion
Migrating a live application from AWS EC2 to DigitalOcean is challenging, but with proper planning—including careful inventory, replication for DB, and use of Floating IP or Load Balancer for cutover—you can minimize downtime and take advantage of Droplets, Spaces, and Managed Databases.
The team is ready to assist in the design and implementation of infrastructure, especially for scenarios requiring GPUs, dedicated trading or gaming VPS, CDNs, and complex networking solutions.









