Running a project on AWS EC2 and thinking about making the move to DigitalOcean? Whether you’re looking to reduce infrastructure costs, simplify server management, or gain more control over your environment, this tutorial walks you through a complete migration from EC2 to a DigitalOcean Droplet.
DigitalOcean is known for its developer-friendly approach, offering an intuitive UI, predictable pricing, and powerful features like one-click apps, managed databases, and built-in monitoring. These qualities make it an attractive option for startups, solo developers, and growing teams who want more focus on building and less on managing infrastructure.
This tutorial ensures you can replicate your environment, move files and data securely, and switch your production traffic with confidence, all while minimizing downtime.
This tutorial is particularly useful for developers, IT professionals, and businesses looking to optimize their cloud infrastructure. By migrating from AWS EC2 to a DigitalOcean Droplet, users can benefit from:
Before starting, ensure you have the following:
Optional, but recommended:
Cloud migrations can be complex, but they don’t have to be chaotic. This step-by-step approach gives you a clear, repeatable process for moving a live application from AWS to DigitalOcean.
Historically, developers and businesses have managed migrations using custom scripts, vendor-specific tools, or manual backups, each with trade-offs in complexity, downtime, and risk. This method focuses on simplicity and reliability, using widely supported tools like SSH, rsync, and mysqldump to streamline the process.
And because the migration lands on DigitalOcean, users benefit from a clean, modern infrastructure experience, designed to get you from deployment to scaling faster and with fewer roadblocks.
Before anything else, identify what you’re running:
cat /etc/os-release
to display the operating system details.systemctl list-units --type=service --state=running
to list all active services. Look for services like Apache, MySQL, or Node.js in the output./var/www/html
for web applications. Use find / -name 'your-app-name'
to locate specific files or directories. Check configuration files in /etc
or within your application’s directory.sudo iptables -L
on the instance to view any local firewall rules.This helps replicate the environment accurately on DigitalOcean.
Head to your DigitalOcean Cloud Panel and:
Once created, note your Droplet’s IP address from the Cloud Panel.
Access your new Droplet using one of the following methods:
~/.ssh/id_rsa
), use:ssh root@your_droplet_ip
ssh -i /path/to/private-key root@your_droplet_ip
ssh root@your_droplet_ip
After you SSH, install necessary packages, for example:
sudo apt update && sudo apt install nginx mysql-server php -y
(or your specific stack: Node.js, Docker, etc.)
Make sure you replicate any system configurations from your EC2 instance.
Use rsync
to copy files from EC2 to Droplet:
rsync -avz -e "ssh -i /path/to/aws-key.pem" ubuntu@your_ec2_ip:/var/www/html/ root@your_droplet_ip:/var/www/html/
Why rsync? It’s fast, secure, and preserves permissions.
If your application uses a database, you’ll need to migrate it from your EC2 instance to your DigitalOcean Droplet. This ensures your application functions correctly in the new environment.
This method is great if you want full control and prefer keeping everything on one server. Just be sure to configure security, backups, and resource limits accordingly. If you choose this route, then follow these steps:
1. Export your database:
For most databases, you’ll first need to create a backup (dump) of your database. Common tools include:
mysqldump
to export your database.pg_dump
for PostgreSQL backups.mongodump
for MongoDB backups.redis-cli
to create a snapshot of your Redis data.Here are some tutorials that can help you with exporting your database:
2. Transfer the database dump to your Droplet:
After exporting the database, use scp or rsync to securely transfer the backup file from your EC2 instance to your new Droplet:
rsync -avz -e "ssh -i /path/to/aws-key.pem" ubuntu@your_ec2_ip:/path/to/backup.sql root@your_droplet_ip:/root/
3. Import the Database on the Droplet:
Once the file is transferred, follow the same DigitalOcean tutorials above to restore the database into your Droplet’s environment.
As an alternative to self-hosting the database on your Droplet, you can offload that responsibility by using DigitalOcean’s Managed Databases. These are production-ready, fully managed database clusters that offer:
To migrate to a Managed Database:
Choose the path that best fits your use case. If you’re just testing or running a small project, hosting the DB on your Droplet may be fine. But for anything production-facing, Managed Databases offer serious long-term advantages.
Pro tip: Managed Databases are especially helpful if you’re planning to scale, want better uptime guarantees, or prefer not to worry about backups, patches, or performance tuning.
With your application and database now hosted on DigitalOcean, you’ll need to update your configuration files to reflect the new environment.
If you are using Nginx, Apache, or any other web server, make sure that the server block or virtual host files are properly configured. You’ll need to update paths, server names, and possibly SSL certificates. For example, with Nginx, you would edit the configuration file like so:
sudo nano /etc/nginx/sites-available/default
Make necessary changes, such as updating the document root or server name. After updating the configuration, don’t forget to reload or restart Nginx to apply the changes:
sudo systemctl restart nginx
Update your application’s database connection strings to point to the correct database host and credentials on the DigitalOcean Droplet. This will involve modifying environment variables or configuration files that store your database connection information.
For example, if your connection string was previously pointing to your EC2 instance, you will now need to update it to point to localhost or the appropriate IP of your Droplet or Managed Database.
If your application relies on environment variables (such as API keys, database credentials, or other configuration settings), make sure these are set on your DigitalOcean Droplet. You can set them directly in your shell profile (~/.bashrc, ~/.bash_profile, or /etc/environment) or in .env files used by your application.
For example, to set a MySQL password environment variable:
export MYSQL_ROOT_PASSWORD='your_password'
Then, load the variables with:
source ~/.bashrc
Before you make your Droplet live, it’s crucial to test your application thoroughly to ensure it works as expected in the new environment. Here are some steps to test:
Ensure that all your application files were successfully transferred to the Droplet. Check that file permissions are intact and that no files were corrupted during the transfer.
Make sure your application can connect to the new database. If you’re using a web framework, it may be helpful to check for any database errors by examining your application logs or testing database queries directly from the command line.
Test all aspects of your application (front-end, back-end, API, etc.). You can either manually perform these tests or use automated testing tools like Selenium, Postman, or cURL to ensure everything is functioning as expected.
Look at system and application logs to check for any errors. You can check system logs with:
sudo journalctl -xe
For application-specific logs, check the log files (e.g., /var/log/nginx/error.log
, /var/log/mysql/error.log
) or wherever your application stores logs.
Now that you’ve verified your application works on the Droplet, it’s time to update your DNS settings to point to your new server.
Login to the control panel of your domain registrar or where you manage the DNS.
Modify the A record for your domain to point to your Droplet’s IP address. For example, you would update:
@ A your_droplet_ip
Set the TTL (Time to Live) value to a low value (e.g., 300 seconds) to ensure DNS changes propagate quickly.
DNS changes can take anywhere from a few minutes to 24 hours to fully propagate across the web. In most cases, you’ll start seeing traffic directed to the Droplet within an hour.
Once DNS propagation is complete, and you’re confident everything is working on your new Droplet, you can fully transition your production traffic. Make sure to monitor your application for any potential issues during the transition.
Once you’ve confirmed everything is running smoothly on DigitalOcean, it’s time for some final maintenance:
Migrating from AWS EC2 to DigitalOcean Droplets can offer several advantages. DigitalOcean is known for its cost-effective pricing model, which can significantly reduce your cloud expenses. Unlike AWS, which has a complex pricing structure, DigitalOcean provides transparent and predictable pricing, making it easier to manage your budget. Additionally, DigitalOcean’s platform is designed with developers in mind, offering a user-friendly interface and a range of tools that simplify infrastructure management. This can lead to more efficient deployment processes and greater control over your environment, allowing you to focus more on development and less on managing infrastructure.
DNS propagation refers to the time it takes for changes to DNS records to be updated across the internet. This process can vary, typically taking anywhere from a few minutes to 24 hours. The duration depends on several factors, including the TTL (Time to Live) settings of your DNS records and the caching policies of ISPs around the world. In most cases, you can expect traffic to start being directed to the new server within an hour, but it’s advisable to monitor the changes to ensure they have fully propagated.
Encountering issues during migration is not uncommon, but there are several steps you can take to troubleshoot and resolve them. First, examine system and application logs for any error messages that might indicate the source of the problem. These logs can provide valuable insights into what might be going wrong. If you’re unable to resolve the issues on your own, DigitalOcean offers robust support services. You can contact their support team for assistance or utilize their free migration service for qualifying projects, which can help ensure a smooth transition.
To ensure optimal performance of your application on DigitalOcean, it’s important to actively monitor its performance using DigitalOcean’s built-in monitoring tools. These tools can help you track resource usage and identify potential bottlenecks. To further enhance performance, consider resizing your Droplets to better match your application’s needs, adding backups to safeguard your data, and implementing load balancers to distribute traffic evenly. These strategies can help maintain high performance levels and ensure your application runs smoothly under varying loads.
Yes, DigitalOcean provides several options for backing up your data to ensure its safety and availability. You can set up automatic weekly or daily backups, which provide a reliable way to restore your system in case of data loss. Additionally, you can take manual Snapshots of your Droplets, allowing you to capture the current state of your system at any time. For more comprehensive backup solutions, consider using services like SnapShooter, which offer additional features and flexibility in managing your backups on DigitalOcean.
In this guide, you’ve learned how to migrate a live application from AWS EC2 to a DigitalOcean Droplet - from assessing your EC2 setup, creating and configuring your new Droplet, transferring files and databases, to testing and switching over DNS with minimal downtime.
This process helps solve real-world challenges like reducing cloud costs, simplifying infrastructure management, and gaining more control over your deployment environment. Whether you’re running a solo project or scaling a production app, moving to DigitalOcean puts you on a platform that’s built for developers, with straightforward pricing and a streamlined experience.
That said, every application stack is different. Depending on what you’re running - whether it’s a LAMP stack, Node.js app, containerized workloads, or something more complex - there may be additional steps needed to tailor the migration to your specific setup.
Need help? You don’t have to do it alone. If you’d like assistance with your migration, DigitalOcean offers a free migration service for qualifying projects. Our team can help ensure a seamless transition, so you can get up and running on DigitalOcean faster and with confidence.
Good luck with your migration, and welcome to the DigitalOcean community!
Continue building with DigitalOcean Gen AI Platform.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!