How to restore Gitlab backup to another disk/folder

Dear all,

Need your help and knowledge on this situation:
We have a self-hosted Gitlab on a cloud Ubuntu server. Gitlab is growing in size and maxed out disk space. We had to upgrade it to a bigger cloud instance type, this includes disk, vCPU and RAM hence the cost is over our heads. So we went and do:

  • Backup Gitlab to a new backup disk by changing the config: success
    gitlab_rails[‘backup_path’] = “/mnt/gitlab_backup/backups”

  • Install Gitlab to a new Ubuntu server (low performance, low disk space, low cost) - same version (15.9.1-ee.0)

  • Create another disk to add to this new server /mnt/gitlab_data/gitlab (the disk is upgradable separately from cloud instance config hence it’d be easier to upgrade next time it maxed out while maintain a low cost)

  • I’ve mounted the backup disk to the new server, copied all config files, granted all required permission, reconfigured gitlab-ctl, Ubuntu 22.04 LTS

Problem: gitlab-backup restore will only restore the backup to their default location /var/opt/gitlab/, not my new disk /mnt/gitlab_data/gitlab.

I tried using gitlab-backup restore -C /mnt/gitlab_data/gitlab/ but ran into ‘No Rakefile found’ error.

If someone know how to deal with this, please help enlightening me.

Thank you very much.

You would need to change the mount point also in /etc/gitlab/gitlab.rb in quite a few places where /var/opt/gitlab appears.

If it was me, I would do it differently, and would have done this.

  1. Create new Ubuntu server.
  2. Mount disk to /var/opt/gitlab instead of /mnt/wherever (saves editing gitlab.rb as mentioned)
  3. Install Gitlab
  4. Run reconfigure to get a basic running version of Gitlab
  5. Restore backup

For the additional disk, it doesn’t matter where you mount it, so easier just to keep it with the default location of /var/opt/gitlab. In the future that disk can most likely be mounted elsewhere in other VM/VPS’s.

1 Like

That definitely worth a try. To be honest, I’m not an advanced Linux user hence mounting a volume directly to /var/opt/gitlab is a new option to me. Thank you for your help. Will keep you updated with the result. :heart:

1 Like

The directory won’t exist at first, since Gitlab isn’t installed, but this isn’t a problem, since you’ll just do:

mkdir /var/opt/gitlab

then mount the partition to /var/opt/gitlab - empty for a new install, then you can just install Gitlab as normal and then do your restore after this and it will all restore to the new partition.

Everything works like a charm. Now when the disk is full I just need to increase size and extend the partition. Thank you captain.

1 Like