How to keep gitlab application backup only on mounted share?

Hi guys, we have an issue with a self-hosted GitLab. Our goal is to store backups only on locally mounted NAS shares and not on the server. It seems no matter what we change in backup settings it saves them on NAS and locally at /var/opt/gitlab/backups (default location).
So far we tried to set gitlab_rails[‘manage_backup_path’] = false (didn’t work out) and completely comment out every setting that is related to managing backup (didn’t work). Of course, we reconfigured gitlab after every change.

We have GitLab Enterprise Edition [13.11.1-ee]

And current backup settings looks like this:

#gitlab_rails[‘manage_backup_path’] = false

Default backup location:

#gitlab_rails[‘backup_path’] = “/var/opt/gitlab/backups”
###! Docs: Back up and restore GitLab | GitLab

Default permissions:

#gitlab_rails[‘backup_archive_permissions’] = 0644

gitlab_rails[‘backup_pg_schema’] = ‘public’

###! The duration in seconds to keep backups before they are allowed to be deleted

Default Backup rotation:

#gitlab_rails[‘backup_keep_time’] = 604800

gitlab_rails[‘backup_upload_remote_directory’] = ‘my.s3.bucket’

gitlab_rails[‘backup_multipart_chunk_size’] = 104857600

gitlab_rails[‘backup_upload_connection’] = {
:provider => ‘Local’,
:local_root => ‘/mnt/nas/Backups’
gitlab_rails[‘backup_upload_remote_directory’] = ‘IT/git’

So as you see everything is commented out except NAS. Has anybody faced such an issue before?

Hi @EugeneBelyaev
If you need your backups in ‘/mnt/nas/Backups/IT/git’ set it up like that

gitlab_rails['backup_upload_connection'] = {
  :provider => 'Local',
  :local_root => '/mnt/nas/Backups/IT'
gitlab_rails['backup_upload_remote_directory'] = 'git'

make sure git user has write permissions.

Also what command do you use to create the backup?

Thank you for your reply balonik, it’s already set up this way and running just fine. The problem is that it also writes backups to the default git location which is local storage “/var/opt/gitlab/backups” and because of this we constantly running out of space. We want to disable writing to local storage, commenting out gitlab_rails[‘backup_path’] = “/var/opt/gitlab/backups” doesn’t help.

Hi, you have two options.

  1. Mount your NFS share to /var/opt/gitlab/backups.
  2. Change the gitlab_rails backup_path to the place you mounted your NFS share if it’s not /var/opt/gitlab/backups and then do gitlab-ctl reconfigure.

If you decide to mount the NFS share to /var/opt/gitlab/backups, make sure that directory is empty prior to mounting and then just copy the data back later. Since it will be a separate mount point, it won’t utilise the space on your disk.

If you decide to choose point 2, then the backups will go to the new location specified and will no longer use /var/opt/gitlab/backups.


I backed up without the GitLab command. Just find where those db files, repositories files and shared objects are and rsync to where ever backup place you want.

By the way, is NAS better than NFS? I have got too many issues using NFS and really want a better replacement.

NFS is just a protocol, NAS is an entire storage device, which allows you to mount SMB/samba, NAS, iSCSI, as well as use rsync. If you are having issues with NFS, you don’t necessarily need a NAS to resolve it. Samba isn’t ideal either, I would far prefer to use NFS though, unless I need to access the files from Windows servers as well as Linux. iSCSI you can mount directly and format accordingly with ext4, or whatever file system you wish - but it can only be mounted once. So if you mount it to gitlab, then you cannot mount it to another server until it has been unmounted from the gitlab server. It all depends on what you are attempting to achieve and what problems you are attempting to resolve.

@Jie : Just copying the files is a pretty bad idea. If anybody is accessing you GitLab instance while you do that you might end up with files that are not consistent (with each other). It’s just like backing up databases, you need to make a dump and back that up. The supplied rake task does backups the right way, but that also means some temporary files are needed, and as local storage is typically faster /var/opt/gitlab/backups are used for those.

@iwalker has explained the difference between NFS and NAS so I won’t go into that.

1 Like

You are probably right. I did back up when I turned off the instance so I didn’t think this too deeply.

For NAS & NFS I was hoping for a better answer but that’s all right.

@Jie if you want a better answer, then explain in more detail what your problem is. NAS is not a protocol - Network Attached Storage is not the same as NFS. NFS is a protocol, like SSHFS, like Samba/SMB.

If you explain your problems, then you can get much more of a detailed response in to what to replace your NFS issues with. And this also depends on your environment. Just Linux, or mix Windows/Linux, or other operating systems. Your message lacked detail, which means we cannot help.

Thank you, as a result, we just attached a new ssd drive to the server and store backups there.