Skip to content

Commit 88e0a71

Browse files
committed
add doc on moving mysql to postgres
1 parent 057330b commit 88e0a71

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Stop Gitlab
2+
3+
```bash
4+
service gitlab stop
5+
```
6+
7+
# Install postgresql
8+
9+
```bash
10+
sudo apt-get install -y postgresql-9.1 postgresql-client libpq-dev
11+
```
12+
13+
# Initial Setup
14+
15+
```bash
16+
# Login to PostgreSQL
17+
sudo -u postgres psql -d template1
18+
19+
# Create a user for GitLab.
20+
template1=# CREATE USER git;
21+
22+
# Create the GitLab production database & grant all privileges on database
23+
template1=# CREATE DATABASE gitlabhq_production OWNER git;
24+
25+
# Quit the database session
26+
template1=# \q
27+
28+
# Try connecting to the new database with the new user
29+
sudo -u git -H psql -d gitlabhq_production
30+
```
31+
32+
# Install postgres gem
33+
34+
```bash
35+
cd ~git/gitlab
36+
sudo -u git -H bundle install --deployment --without development test mysql aws
37+
```
38+
39+
# Dump the mysql database
40+
41+
```bash
42+
mysqldump --compatible=postgresql --default-character-set=utf8 -r /tmp/gitlabhq_production.mysql -u root -p gitlabhq_production
43+
```
44+
45+
# Convert the mysql to postgres import
46+
47+
```bash
48+
wget https://raw.github.com/lanyrd/mysql-postgresql-converter/master/db_converter.py -O /tmp/db_converter.py
49+
python db_converter.py /tmp/gitlab_production.mysql /tmp/gitlab_production.psql
50+
```
51+
52+
# Import the database
53+
54+
```bash
55+
sudo -u git -H psql -d gitlabhq_production -f /tmp/gitlab_production.psql
56+
```
57+
58+
# Update database config
59+
60+
```bash
61+
cd ~git/gitlab/config
62+
sudo -u git -H cp database.yml database.yml.backup
63+
sudo -u git -H cp database.yml.postgresql database.yml
64+
```
65+
66+
# Start Gitlab service
67+
68+
```bash
69+
service gitlab start
70+
service nginx restart
71+
```

0 commit comments

Comments
 (0)