- Convert an external PostgreSQL to a Linux package installation by using a backup
- Convert an external PostgreSQL to a Linux package installation in-place
Convert a self-compiled installation to a Linux package installation
If you installed GitLab by using the self-compiled installation method, you can convert your instance to a Linux package instance.
When converting a self-compiled installation:
- You must convert to the exact same version of GitLab.
- You must configure settings in
/etc/gitlab/gitlab.rb
because settings in files such asgitlab.yml
,puma.rb
andsmtp_settings.rb
are lost.
To convert your self-compiled installation to a Linux package installation:
-
Create a backup from your current self-compiled installation:
cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
- Install GitLab using a Linux package.
- Copy the backup file to the directory
/var/opt/gitlab/backups/
of the new server. -
Restore the backup in the new installation (detailed instructions):
# This command will overwrite the contents of your GitLab database! sudo gitlab-backup restore BACKUP=<FILE_NAME>
The restore takes a few minutes depending on the size of your database and Git data.
- Because all settings are stored in
/etc/gitlab/gitlab.rb
in Linux package installations, you must reconfigure the new installation . Individual settings must be manually moved from self-compiled installation files such asgitlab.yml
,puma.rb
, andsmtp_settings.rb
. For all available options, see thegitlab.rb
template. - Copy the secrets from the old self-compiled installation to the new Linux package installation:
- Restore secrets related to Rails. Copy the values of
db_key_base
,secret_key_base
andotp_key_base
from/home/git/gitlab/config/secrets.yml
(self-compiled installation) to the equivalent ones in/etc/gitlab/gitlab-secrets.json
(Linux package installation). -
Copy the contents of
/home/git/gitlab-shell/.gitlab_shell_secret
(self-compiled installation) tosecret_token
in/etc/gitlab/gitlab-secrets.json
(Linux package installation). It looks something like:{ "gitlab_workhorse": { "secret_token": "..." }, "gitlab_shell": { "secret_token": "..." }, "gitlab_rails": { "secret_key_base": "...", "db_key_base": "...", "otp_key_base": "...", } ... }
- Restore secrets related to Rails. Copy the values of
-
Reconfigure GitLab to apply the changes:
sudo gitlab-ctl reconfigure
-
If you migrated
/home/git/gitlab-shell/.gitlab_shell_secret
, you must restart Gitaly:sudo gitlab-ctl restart gitaly
Convert an external PostgreSQL to a Linux package installation by using a backup
You can convert an external PostgreSQL installation to a Linux package PostgreSQL installation by using a backup. You must use the same GitLab version when you do this.
To convert an external PostgreSQL installation to a Linux package PostgreSQL installation by using a backup:
- Create a backup from the non-Linux package installation
- Restoring the backup in the Linux package installation.
-
Run the
check
task:sudo gitlab-rake gitlab:check
-
If you receive an error similar to
No such file or directory @ realpath_rec - /home/git
, run:find . -lname /home/git/gitlab-shell/hooks -exec sh -c 'ln -snf /opt/gitlab/embedded/service/gitlab-shell/hooks $0' {} \;
This assumes that gitlab-shell
is located in /home/git
.
Convert an external PostgreSQL to a Linux package installation in-place
You can convert an external PostgreSQL installation to a Linux package PostgreSQL installation in-place.
These instructions assume:
- You are using PostgreSQL on Ubuntu.
- You have an Linux package matching your current GitLab version.
- Your self-compiled installation of GitLab uses all the default paths and users.
- The existing home directory of the Git user (
/home/git
) will be changed to/var/opt/gitlab
.
To convert an external PostgreSQL installation to a Linux package PostgreSQL installation in-place:
-
Stop and disable GitLab, Redis, and NGINX:
# Ubuntu sudo service gitlab stop sudo update-rc.d gitlab disable sudo service nginx stop sudo update-rc.d nginx disable sudo service redis-server stop sudo update-rc.d redis-server disable
- If you are using a configuration management system to manage GitLab on your server, disable GitLab and its related services there.
-
Create a
gitlab.rb
file for your new setup:sudo mkdir /etc/gitlab sudo tee -a /etc/gitlab/gitlab.rb <<'EOF' # Use your own GitLab URL here external_url 'http://gitlab.example.com' # We assume your repositories are in /home/git/repositories (default for source installs) git_data_dirs({ 'default' => { 'path' => '/home/git' } }) # Re-use the PostgreSQL that is already running on your system postgresql['enable'] = false # This db_host setting is for Debian PostgreSQL packages gitlab_rails['db_host'] = '/var/run/postgresql/' gitlab_rails['db_port'] = 5432 # We assume you called the GitLab DB user 'git' gitlab_rails['db_username'] = 'git' EOF
-
Now install the Linux package and reconfigure the installation:
sudo gitlab-ctl reconfigure
-
Because the
gitlab-ctl reconfigure
run has changed the home directory of the Git user and OpenSSH can no longer find itsauthorized_keys
file, rebuild the keys file:sudo gitlab-rake gitlab:shell:setup
You should now have HTTP and SSH access to your GitLab server with the repositories and users that were there before.
- If you can log into the GitLab web interface, reboot your server to make sure none of the old services interfere with the Linux package installation.
- If you are using special features such as LDAP, you must put your settings in
gitlab.rb
. For more information, see the settings documentation.