Upgrade steps were taken from this article.
sudo service postgresql stop 9.3
sudo service postgresql stop 9.4
sudo su - postgres
/usr/lib/postgresql/9.4/bin/pg_upgrade -b /usr/lib/postgresql/9.3/bin/ -B /usr/lib/postgresql/9.4/bin/ -d /var/lib/postgresql/9.3/main -D /var/lib/postgresql/9.4/main -o ' -c config_file=/etc/postgresql/9.3/main/postgresql.conf' -O ' -c config_file=/etc/postgresql/9.4/main/postgresql.conf'
exit
Change port to 5433 (line 62)
sudo vi /etc/postgresql/9.3/main/postgresql.conf
Change port to 5432
sudo vi /etc/postgresql/9.4/main/postgresql.conf
Start postgresql 9.4
sudo service postgresql start 9.4
Now you can remove postgresql 9.3 if you need
sudo apt-get remove postgresql-9.3