默认情况下GitLab的备份目录在/var/opt/gitlab目录下backups子目录里面;通过修改配置文件/etc/gitlab/gitlab.rb来自定义backups目录
[root@izuf6fy69k7l7e20jogcj7z ~]# ll /var/opt/gitlab/ total 80 drwxr-x--- 3 gitlab-prometheus root 4096 Aug 27 22:35 alertmanager drwx------ 2 git root 4096 Aug 19 22:34 backups -rw------- 1 root root 38 Aug 19 22:35 bootstrapped drwxr-xr-x 2 root root 4096 Aug 29 00:42 crond drwx------ 2 git root 4096 Aug 27 22:59 gitaly drwx------ 3 git root 4096 Aug 19 22:34 git-data drwxr-xr-x 3 git root 4096 Aug 19 22:34 gitlab-ci drwxr-xr-x 2 git root 4096 Aug 27 22:35 gitlab-monitor drwxr-xr-x 9 git root 4096 Aug 27 22:35 gitlab-rails drwx------ 2 git root 4096 Aug 27 22:34 gitlab-shell drwxr-x--- 2 git gitlab-www 4096 Aug 27 22:59 gitlab-workhorse drwx------ 3 root root 4096 Aug 30 21:09 logrotate drwxr-x--- 10 root gitlab-www 4096 Aug 27 22:59 nginx drwxr-xr-x 3 root root 4096 Aug 19 22:35 node-exporter drwx------ 2 gitlab-psql root 4096 Aug 27 22:35 postgres-exporter drwxr-xr-x 3 gitlab-psql root 4096 Aug 27 22:59 postgresql drwxr-x--- 4 gitlab-prometheus root 4096 Aug 27 22:35 prometheus -rw-r--r-- 1 root root 191 Aug 29 00:42 public_attributes.json drwxr-x--- 2 gitlab-redis git 4096 Aug 30 21:18 redis -rw-r--r-- 1 root root 40 Aug 19 22:34 trusted-certs-directory-hash
通过修改配置文件/etc/gitlab/gitlab.rb来自定义backups目录
1、首先创建自定义存放目录/backups:mkdir /git-data/backups
[root@izuf6fy69k7l7e20jogcj7z ~]# mkdir /git-data/backups [root@izuf6fy69k7l7e20jogcj7z ~]# ll /git-data/ total 8 drwxr-xr-x 2 root root 4096 Aug 30 21:23 backups drwxrws--- 4 git root 4096 Aug 27 22:59 repositories
2、配置backups目录属主和属组为git:chown -R git.git /git-data/backups/
[root@izuf6fy69k7l7e20jogcj7z ~]# chown -R git.git /git-data/backups/ [root@izuf6fy69k7l7e20jogcj7z ~]# ll /git-data/ total 8 drwxr-xr-x 2 git git 4096 Aug 30 21:23 backups drwxrws--- 4 git root 4096 Aug 27 22:59 repositories
3、编辑修改配置文件/etc/gitlab/gitlab.rb
gitlab_rails['backup_path'] = "/git-data/backups" <<自定义备份目录路径 gitlab_rails['backup_archive_permissions'] = 0644 <<生成的备份文件权限 gitlab_rails['backup_keep_time'] = 604800 <<自定义备份保留时间(单位秒;默认 604800 秒=7 天)
4、执行命令gitlab-ctl reconfigure重载配置文件