If you’re running low on disk space or simply want to move the data this script will help. Of course modify the path as needed.
First double check your paths
df -h
# Backup GitLab Configuration
sudo cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bk
# Set the data directory path
sed -i "s|# git_data_dirs({\"default\" => \"/var/opt/gitlab/git-data\"})|git_data_dirs({\"default\" => \"/mnt/data01/gitlab\"})|" /etc/gitlab/gitlab.rb
# Prevent users from writing to the repositories while you move them.
sudo gitlab-ctl stop
# Note there is _no_ slash behind 'repositories', but there _is_ a
# slash behind 'git-data'.
sudo rsync -av /var/opt/gitlab/git-data/repositories /mnt/data01/gitlab/git-data/
# Start the necessary processes and run reconfigure to fix permissions
# if necessary
sudo gitlab-ctl upgrade
# Double-check directory layout in /mnt/data01/gitlab/git-data. Expected output:
# repositories
sudo ls /mnt/data01/gitlab/git-data/
# Just in case
sudo gitlab-ctl reconfigure
# Done! Start GitLab and verify that you can browse through the repositories in
# the web interface.
sudo gitlab-ctl start
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.