Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to migrate from Heroku to Digital Ocean

Francisco Quinones asked in Servers

Chris, I'm thinking of moving to digital Ocean from Heroku but my knowledge on this topic is cloudy. Can you tell us about the differences between the 2 service? and benefit.

Reply

Hey Francisco,

The main difference is that on Heroku, you don't have to manage your server, update versions, patch security things, etc. It's a lot of work to run your own server but if you're willing to learn and do that, it can save you money, but it definitely won't save you time. :)

Heroku really saves a ton of time because there are so many little security patches to update constantly on your nginx, passenger, postgres, rails, ruby, redis, etc installs. That can be a fair amount of work not to mention if you want to setup backups or any of those things. You can check out the guides section in the navbar if you want to see some of my tutorials on how to do all this yourself.

The nice part is you can run all this stuff on a $10 or $20/mo server on Digital Ocean, whereas Heroku can get up to $100+/mo pretty fast. I will say, you'll probably still save time using Heroku, and if you're building something that makes money, then Heroku is probably going to be worth it. For side projects, or ones that you want to learn all the ropes of managing a server, then Digital Ocean is pretty great.

Reply

For the actual migration, the only thing you'll really need to make sure you do is copy over your database. You can download it from Heroku and then upload it to your Digital Ocean server. You can google instructions on how to move a database to another server. It's not too bad, but you'll want to be careful that when you do this, your users aren't still using the old site where you would lose some data moving servers. You'll need to disable the current app on Heroku so that you don't lose data in the migration and then change your DNS to point to the new server on Digital Ocean.

Reply

thnx Chris for taking the time.

Reply

@Francisco Quinones How did you manage to migrate your heroku database on digital ocean?

Reply

@malav I haven't at the moment we are upgrading to rails 5 so until we finish no migration. :)

Reply

Ohk Thanks.. But do you find any article or solution for that? I deployed my site code on digital ocean everything is working fine. Now Heroku rotates credentials periodically and updates applications where this database is attached. And i have exported database from heroku which is in Binary format. Now how i supposed to place that file or data to my digital ocean's postgres database which i have created at time of deploying. I followed https://gorails.com/deploy/ubuntu/16.04 this article to deploy on digitalocean.

Reply

Hey Malav,

Are you just trying to dump your old DB and import it into your new server? If so...

On your old server, dump the database:

pg_dump name_of_your_old_database > /path/to/dump/database_backup.sql

Once dumped, you'll need to transfer the *.sql file to your new server then import the database with:

psql name_of_your_new_database -f /path/to/database_backup.sql

Check: https://www.digitalocean.com/community/tutorials/how-to-backup-postgresql-databases-on-an-ubuntu-vps

Reply

Hey Jacob, Thanks for reply. I am moving my site from Heroku free dynos to DigitalOcean paid hosting. So my database is on Heroku. I have downloaded binary format of my db dump from Heroku. Now i want to move that file to DigitalOcean as my database. I have created username and database name for Postgres while deploying code on DigitalOcean. Now I just want to copy all the content of that binary file to that database.

Reply

Check out this page and scroll to the bottom for restore info: http://postgresguide.com/utilities/backup-restore.html

From the link:

If your database already exists you only need to run the following:

pg_restore -Fc database.bak # restore compressed binary format
pg_restore -Ft database.tar # restore tarball

However, if you're creating your database new from the restore you'll want to run a command similar to the following:

pg_restore -Fc -C database.bak # restore compressed binary format
pg_restore -Ft -C database.tar # restore tarball
Reply

Chris, will you be extending Hatch to do patching/updating? tim

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,972+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.