Problem to solve
Im using GitLab Enterprise Edition [14.8.2-ee], I'm trying to change backup_path to my expected directory. I changed the setting in file /etc/gitlab/gitlab.rb:
gitlab_rails['backup_path'] = "home/gitlab/backups"
Then run reconfigure, and verify configuration:
[root@OFFICE_GITLAB ~]# cat /var/opt/gitlab/gitlab-rails/etc/gitlab.yml | grep -C10 'backup'
# 4. Advanced settings
# ==========================
## Repositories settings
repositories:
# Paths where repositories can be stored. Give the canonicalized absolute pathname.
# NOTE: REPOS PATHS MUST NOT CONTAIN ANY SYMLINK!!!
storages: {"default":{"path":"/var/opt/gitlab/git-data/repositories","gitaly_address":"unix:/var/opt/gitlab/gitaly/gitaly.socket"}}
## Backup settings
backup:
path: "home/gitlab/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
gitaly_backup_path: "/opt/gitlab/embedded/bin/gitaly-backup" # Path of the gitaly-backup binary (default: searches $PATH)
archive_permissions: # Permissions for the resulting backup.tar file (default: 0600)
keep_time: # default: 0 (forever) (in seconds)
pg_schema: # default: nil, it means that all schemas will be backed up
upload:
# Fog storage connection settings, see http://fog.io/storage/ .
connection:
# The remote 'directory' to store your backups. For S3, this would be the bucket name.
remote_directory:
multipart_chunk_size:
encryption:
encryption_key:
storage_options: {}
storage_class:
## Pseudonymizer settings
pseudonymizer:
manifest:
Then run command:
gitlab-backup create BACKUP=$(date +%d%m%Y%H%M%S)
There is error:
[root@OFFICE_GITLAB crons]# sudo gitlab-backup create BACKUP=$(date +%d%m%Y%H%M%S)
2024-03-11 17:46:22 +0800 -- Dumping database ...
rake aborted!
Errno::EACCES: Permission denied @ dir_s_mkdir - /opt/gitlab/embedded/service/gitlab-rails/home
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/database.rb:28:in `dump'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:71:in `run_create_task'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:36:in `block in create'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:35:in `each'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:35:in `create'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:12:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:backup:create
(See full trace by running task with --trace)
It seems that the Backup task is trying to create directories as same as the setting gitlab_rails['backup_path'], but in the /opt/gitlab/embedded/service/gitlab-rails/ directory. Then I run this:
mkdir -p /opt/gitlab/embedded/service/gitlab-rails/home/gitlab/backups
chmod -R 777 /opt/gitlab/embedded/service/gitlab-rails/home/gitlab/backups
Then I run again the backup command, and it can generates backup but all data is located in this directory /opt/gitlab/embedded/service/gitlab-rails/home/gitlab/backups, not the expected directory /home/gitlab/backups:
sudo gitlab-backup create BACKUP=$(date +%d%m%Y%H%M%S)
2024-03-11 17:58:26 +0800 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2024-03-11 17:58:44 +0800 -- done
2024-03-11 17:58:44 +0800 -- Dumping repositories ...
....
[root@OFFICE_GITLAB backups]# cd /opt/gitlab/embedded/service/gitlab-rails/home/gitlab/backups
[root@OFFICE_GITLAB backups]# du -sh ./*
99M ./db
8.0G ./repositories
So Gitlab is generating backup data to /opt/gitlab/embedded/service/gitlab-rails/home/gitlab/backups instead of /home/gitlab/backups . Please help me, how to fix this ?
Thank you all.