GitHub two factor authentication with IntelliJ

I’m a big fan of the IntelliJ products and derivatives, particularly Pycharm and Android Studio.

I also use two factor authentication (2fa) on every site that supports it. GitHub, no stranger to awesomeness, supports 2fa like a boss!

The easiest way to make your IntelliJ IDE jive with your 2fa-enabled GitHub account is to use personal API tokens. You have to be careful with these, because they’re a form of single-factor authentication, but since they’re long, random, and typically used for one purpose (i.e., you’re IDE), I think their overall impact to your account’s security is acceptable.

After you’ve created your personal API token (I used the default settings), open your settings dialog in your IntelliJ IDE. pycharm_github_settings

For “Auth Type” pick “Token.” Insert your token into the field, click “Test” to see if it worked, and you’re good to go!

Backing up WordPress on OpenShift

When I logged into my WordPress admin page today, I saw a friendly message saying that it’s time to upgrade.

WordPress recommends that you backup before upgrading. If your blog is hosted on like mine is, then here’s a process to backup your WordPress gear.

First, do a git clone to pull down your php environment. In this example, my WordPress gear is called ‘blog’.

[jason@localhost ~]$ rhc git-clone blog
Cloning into 'blog'...
Your application Git repository has been cloned to '/home/jason/blog/blog'

Next, you need to back up your MySQL database. The general process for this is

  1. SSH into your gear
  2. Create a temp directory if one doesn’t already exist
  3. mysqldump your WordPress database using the OpenShift environment variables
  4. SCP your dump to a backup location

So here we go…

[jason@localhost ~]$ cd blog
[jason@localhost blog]$ rhc ssh blog
[ 51b4c584500446eb79000070]> mkdir app-root/data/tmp
[ 51b4c584500446eb79000070]> mysqldump --user="${OPENSHIFT_MYSQL_DB_USERNAME}" --password="${OPENSHIFT_MYSQL_DB_PASSWORD}" --host="${OPENSHIFT_MYSQL_DB_HOST}" --port="${OPENSHIFT_MYSQL_DB_PORT}" --no-create-info --complete-insert --extended-insert=FALSE blog > app-root/data/tmp/wordpress.sql
[ 51b4c584500446eb79000070]> exit
[jason@localhost blog]$ rhc apps
blog @ (uuid: 51b4c584500446eb79000070)
  Domain:          callaway
  Created:         Jun 09  2:12 PM
  Gears:           1 (defaults to small)
  Git URL:         ssh://
  Initial Git URL: git://
  Deployment:      auto (on git push)

  php-5.3 (PHP 5.3)
    Gears: Located with mysql-5.1

  mysql-5.1 (MySQL 5.1)
    Gears:          Located with php-5.3
    Database Name:  blog
    Password:       redacted
    Username:       redacted

You have 1 applications
[jason@localhost blog]$ scp .
wordpress.sql                                        100% 1288KB   1.3MB/s   00:00

A few notes about this approach:

  • It could be better automated by doing the mysqldump non-interactively
  • The mysqldump options omit the schema. If you want to grab both schema and content, remove the --no-create-info option
  • If you wanted to restore, you’d do a git push from your cloned directory, then scp the saved sql, ssh in, and then load the sql like this:
    • mysql --user="${OPENSHIFT_MYSQL_DB_USERNAME}" --password="${OPENSHIFT_MYSQL_DB_PASSWORD}" --host="${OPENSHIFT_MYSQL_DB_HOST}" --port="${OPENSHIFT_MYSQL_DB_PORT}" blog < ~/app-root/data/tmp/wordpress.sql
  • There are probably more clever ways to do this. This process was the first one that jumped into my head
      If you have better ways of backing up WordPress, sound off!