Here are some of the common tasks that I run on Heroku and I often forget the syntax for running them.

Creating an app on Heroku

  1. App names have to be unique in the entire system. If you are going to be deploying multiple apps on Heroku, it may be test to think of a common convention to make it easier to find your apps later.
    heroku apps:create

Pushing your app to Heroku

  1. Check to see if you already have a git remote created that points to the git repository for your app on Heroku.
    From your code repository, type

     git remote -v

    You should see your heroku remote already added to the list

  2. If your git remote isn’t already added, add it to your git remote
     git remote add [remote name] [heroku git file]
  3. Push your code to the heroku remote
     git push [remote name] master

Pushing a different branch for your Heroku app

From your console, type: git push [remote name] [local branch name]:[remote branch name]

Database Management

Reference: https://devcenter.heroku.com/articles/heroku-postgres-import-export

Listing available backups from a Heroku app

heroku pgbackups --app [App name]

There are 2 kinds of backups – automated and manual. Automated backups will have an a prefix and the manual backups will have a b prefix

Backing up your database to a temporary URL

heroku pgbackups:url --app [App name]

This will generate a temporary url that you can access so that you can do a restore without copying the database locally to your machine

Restore your Postgres database from another source

heroku pgbackups:restore [ [BACKUP_ID|BACKUP_URL]]

Common syntax: heroku pgbackups:restore DATABASE ‘https://s3.amazonaws.com/me/items/3H0q/mydb.dump’

– this is the database url from your config. By default, leaving it as DATABASE tends to work if your DATABASE_URL already is set up.

Don’t forget to enclose your URL in a single quote or double quote otherwise it won’t be accepted

Additional Tips

  1. I’ve typically found that you have to reset the database before restoring it. It tends to create less problems when you do that. Restoring a database on top of an existing one tends to create issues.

Adding Add-on apps

Add-ons are what makes Heroku an extremely powerful platform for developers. It greatly reduces the amount of time to manage your infrastructure and allows you to focus instead on development. Most of the add-ons have a free or beginner version that gives you full access to the functionality but for a limited amount allowing you to truly test out the capabilities.

The syntax for Heroku Add-ons are:

heroku addons:add :

Some of the add-ons that I really like are:

PostgreSQL Backups

heroku addons:add pgbackups:

I typically only use the auto-month plan which gives you 2 manual backups, 5 weeklies and 7 dailies.

Heroku Postgres Databases

heroku addons:add heroku-postgresql:

dev – this is for basic development

basic – this is for any non-production environment

standard – this is for any starter production environment

Papertrail Logging

heroku addons:add papertrail:

choklad – I find that this is more then enough for my current needs

Redis To Go Data Store

heroku addons:add redistogo:

nano – this is the free plan

Opinions about People, Process and Technology

Optimization WordPress Plugins & Solutions by W3 EDGE