|  | 
|  | 1 | +# Usage of PostgreSQL 9.3 | 
|  | 2 | + | 
|  | 3 | +``` | 
|  | 4 | +Distribution      : Debian Wheezy | 
|  | 5 | +GitLab version    : 7.x | 
|  | 6 | +Database          : PostgreSQL | 
|  | 7 | +Contributors      : @bionix | 
|  | 8 | +``` | 
|  | 9 | + | 
|  | 10 | +This recipe shows how to upgrade the PostrgreSQL database from version 9.1 to 9.3. | 
|  | 11 | +It is **strongly recommended** to take a [backup][] of your GitLab database before | 
|  | 12 | +following the next steps. | 
|  | 13 | + | 
|  | 14 | +## Install PostgreSQL 9.3 | 
|  | 15 | + | 
|  | 16 | +Install the [official PostgreSQL Debian/Ubuntu repository][apt]: | 
|  | 17 | + | 
|  | 18 | +    cat >> /etc/apt/sources.list.d/pgdg.list << EOF | 
|  | 19 | +    deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main | 
|  | 20 | +    EOF | 
|  | 21 | + | 
|  | 22 | +Install the repository signing key: | 
|  | 23 | + | 
|  | 24 | +    sudo apt-get install wget ca-certificates | 
|  | 25 | +    wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | 
|  | 26 | + | 
|  | 27 | +Update your apt lists: | 
|  | 28 | + | 
|  | 29 | +    sudo apt-get update | 
|  | 30 | + | 
|  | 31 | +Upgrade your installed packages: | 
|  | 32 | + | 
|  | 33 | +    sudo apt-get upgrade | 
|  | 34 | + | 
|  | 35 | +## Intregation in the manual installation process | 
|  | 36 | + | 
|  | 37 | +If you arrive the point 4 in the manual [4. Database][db-manual], replace the | 
|  | 38 | +first step with the following command: | 
|  | 39 | + | 
|  | 40 | +    sudo apt-get install -y postgresql-9.3 postgresql-client-9.3 libpq-dev | 
|  | 41 | + | 
|  | 42 | +After that, follow the normal manual instructions. | 
|  | 43 | + | 
|  | 44 | +## Upgrade from PostgreSQL version 9.1 to 9.3 | 
|  | 45 | + | 
|  | 46 | +Stop your Gitlab service: | 
|  | 47 | + | 
|  | 48 | +    sudo service gitlab stop | 
|  | 49 | + | 
|  | 50 | +Install all PostgreSQL packages for your environment: | 
|  | 51 | + | 
|  | 52 | +    sudo apt-get install -y postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 postgresql-client-9.3 libpq-dev | 
|  | 53 | + | 
|  | 54 | +Extend your PostgreSQL 9.3. server with your extensions: | 
|  | 55 | + | 
|  | 56 | +    sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'" | 
|  | 57 | +    sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'" | 
|  | 58 | + | 
|  | 59 | +Stop your PostgreSQL server daemons (both!): | 
|  | 60 | + | 
|  | 61 | +    sudo service postgresql stop | 
|  | 62 | + | 
|  | 63 | +Make the migration from 9.1 to 9.3: | 
|  | 64 | + | 
|  | 65 | +    sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade \ | 
|  | 66 | +                            -b /usr/lib/postgresql/9.1/bin \ | 
|  | 67 | +                            -B /usr/lib/postgresql/9.3/bin \ | 
|  | 68 | +                            -d /var/lib/postgresql/9.1/main/ \ | 
|  | 69 | +                            -D /var/lib/postgresql/9.3/main/ \ | 
|  | 70 | +                            -O " -c config_file=/etc/postgresql/9.3/main/postgresql.conf" \ | 
|  | 71 | +                            -o " -c config_file=/etc/postgresql/9.1/main/postgresql.conf"' | 
|  | 72 | + | 
|  | 73 | +Remove your old PostgreSQL version, if you have no issues: | 
|  | 74 | + | 
|  | 75 | +    sudo apt-get remove -y postgresql-9.1 | 
|  | 76 | + | 
|  | 77 | +Change the listen port of your PostgreSQL 9.3 server: | 
|  | 78 | + | 
|  | 79 | +    sudo sed -i "s:5433:5432:g" /etc/postgresql/9.3/main/postgresql.conf | 
|  | 80 | + | 
|  | 81 | +Start your PostgreSQL service: | 
|  | 82 | + | 
|  | 83 | +    sudo service postgresql start | 
|  | 84 | + | 
|  | 85 | +Start your Gitlab service: | 
|  | 86 | +    sudo service gitlab start | 
|  | 87 | + | 
|  | 88 | +Done! | 
|  | 89 | + | 
|  | 90 | +[backup]: http://doc.gitlab.com/ce/raketasks/backup_restore.html | 
|  | 91 | +[apt]: https://wiki.postgresql.org/wiki/Apt | 
|  | 92 | +[db-manual]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#4-database | 
0 commit comments