Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
6be0188b
Commit
6be0188b
authored
May 19, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rebuild indexes after a MySQL conversion
parent
dca537ab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
5 deletions
+33
-5
doc/update/mysql_to_postgresql.md
doc/update/mysql_to_postgresql.md
+33
-5
No files found.
doc/update/mysql_to_postgresql.md
View file @
6be0188b
# Migrating GitLab from MySQL to Postgres
# Migrating GitLab from MySQL to Postgres
If you are replacing MySQL with Postgres while keeping GitLab on the same
If you are replacing MySQL with Postgres while keeping GitLab on the same
server all you need to do is to export from MySQL and import into Postgres as
server all you need to do is to export from MySQL, import into Postgres and
described below. If you are also moving GitLab to another server, or if you are
rebuild the indexes as described below. If you are also moving GitLab to
switching to omnibus-gitlab, you may want to use a GitLab backup file. The
another server, or if you are switching to omnibus-gitlab, you may want to use
second part of this documents explains the procedure to do this.
a GitLab backup file. The second part of this documents explains the procedure
to do this.
## Export from MySQL and import into Postgres
## Export from MySQL and import into Postgres
...
@@ -21,9 +22,35 @@ mysqldump --compatible=postgresql --default-character-set=utf8 -r databasename.m
...
@@ -21,9 +22,35 @@ mysqldump --compatible=postgresql --default-character-set=utf8 -r databasename.m
python db_converter.py databasename.mysql databasename.psql
python db_converter.py databasename.mysql databasename.psql
psql -f databasename.psql -d gitlabhq_production
psql -f databasename.psql -d gitlabhq_production
# Rebuild indexes (see below)
sudo service gitlab start
sudo service gitlab start
```
```
## Rebuild indexes
The lanyrd database converter script does not preserve all indexes, so we have
to recreate them ourselves after migrating from MySQL. It is not necessary to
shut down GitLab for this process.
```
# Clone the database converter on your Postgres-backed GitLab server
cd /tmp
git clone https://github.com/gitlabhq/mysql-postgresql-converter.git
# Stash changes to db/schema.rb to make sure we can find the right index statements
cd /home/git/gitlab
sudo -u git -H git stash
# Generate the `CREATE INDEX CONCURRENTLY` statements based on schema.rb
cd /tmp/mysql-to-postgresql-converter
ruby index_create_statements.rb /home/git/gitlab/db/schema.rb > index_create_statements.psql
# Execute the SQL statements against the GitLab database
sudo -u git psql -f index_create_statements.psql -d gitlabhq_production
```
## Converting a GitLab backup file from MySQL to Postgres
## Converting a GitLab backup file from MySQL to Postgres
GitLab backup files (
<timestamp>
_gitlab_
backup.tar) contain a SQL dump. Using
GitLab backup files (
<timestamp>
_gitlab_
backup.tar) contain a SQL dump. Using
...
@@ -64,5 +91,6 @@ sudo -u git -H python mysql-postgresql-converter/db_converter.py gitlabhq_produc
...
@@ -64,5 +91,6 @@ sudo -u git -H python mysql-postgresql-converter/db_converter.py gitlabhq_produc
sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql
sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql
# Done! TIMESTAMP_gitlab_backup.tar can now be restored into a Postgres GitLab installation.
# Done! TIMESTAMP_gitlab_backup.tar can now be restored into a Postgres GitLab
# installation. Remember to recreate the indexes after the import.
```
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment