Book Image

Heroku Cookbook

By : Mike Coutermarsh
Book Image

Heroku Cookbook

By: Mike Coutermarsh

Overview of this book

Heroku is a Platform as a Service that enables developers to rapidly deploy and scale their web applications. Heroku is designed for developer happiness, freeing developers from doing system administrative tasks such as configuring servers and setting up load balancers. Developers are able to focus on what they do best, building web applications, while leaving the details of deployment and scaling to the experts at Heroku. This practical guide is packed with step-by-step solutions to problems faced by every production-level web application hosted on Heroku. You'll quickly get comfortable with managing your Heroku applications from the command line and then learn everything you need to know to deploy and administer production-level web applications.
Table of Contents (17 chapters)
Heroku Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a database backup


In case disaster strikes, you should always have a recent backup of your database that is somewhere accessible and easy to restore from so that you can get back up and running quickly. In this recipe, you will learn how to have Heroku automatically back up data for you. You'll also learn how to manually create backups and store them away from Heroku for extra peace of mind.

How to do it…

To begin, we'll need to open up a terminal and navigate to our Heroku application:

  1. We can enable database backups with the Heroku add-on PG Backups. There are three different backup options, and they are all free. The best option does daily backups and retains our data for up to one month. Let's install that now:

    $ heroku addons:add pgbackups:auto-month
    

    Note

    To see the other plans, take a look at the PG Backups add-on (https://addons.heroku.com/pgbackups).

  2. Now that the add-on is installed, we can use it to capture a backup of our database:

    $ heroku pgbackups:capture
    HEROKU_POSTGRESQL_GRAY_URL...