File tree Expand file tree Collapse file tree 8 files changed +141
-0
lines changed
templates/gitlab-backup-cli
spec/chef/cookbooks/gitlab/recipes Expand file tree Collapse file tree 8 files changed +141
-0
lines changed Original file line number Diff line number Diff line change 149149dependency 'chef-acme'
150150dependency 'gitlab-ctl'
151151dependency 'gitlab-psql'
152+ dependency 'gitlab-backup-cli'
152153dependency 'gitlab-redis-cli'
153154dependency 'gitlab-healthcheck'
154155
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright:: Copyright (c) 2024 GitLab Inc.
3+ # License:: Apache License, Version 2.0
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+ #
17+ name 'gitlab-backup-cli'
18+
19+ license 'Apache-2.0'
20+ license_file File . expand_path ( 'LICENSE' , Omnibus ::Config . project_root )
21+
22+ skip_transitive_dependency_licensing true
23+
24+ build do
25+ # Create a wrapper for the gitlab-backup-cli tool
26+ erb dest : "#{ install_dir } /bin/gitlab-backup-cli" ,
27+ source : 'gitlab_backup_cli_wrapper.erb' ,
28+ mode : 0755 ,
29+ vars : { install_dir : install_dir }
30+ end
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ # Export the environment variables
6+ PATH=" /opt/gitlab/embedded/bin${PATH+: }${PATH} "
7+
8+ export PATH
9+ export GITLAB_BACKUP_CLI_CONFIG_FILE=" <%= install_dir %>/etc/gitlab-backup-cli-config.yml"
10+
11+ gitlab_backup_cli=" <%= install_dir %>/embedded/service/gitlab-rails/bin/gitlab-backup-cli"
12+
13+ error_echo ()
14+ {
15+ echo " $1 " >&2
16+ }
17+
18+ if [[ ! -f ${gitlab_backup_cli} ]] ; then
19+ error_echo " $0 error: could not load ${gitlab_backup_cli} "
20+ error_echo " Either you are not allowed to execute the binary, or it does not exist yet."
21+ error_echo " You can generate it with: sudo gitlab-ctl reconfigure"
22+ exit 1
23+ fi
24+
25+ # Executes the gitlab-backup-cli tool with embedded ruby
26+ " ${gitlab_backup_cli} " " ${@ } "
Original file line number Diff line number Diff line change 8383# `account` custom resource will not create them.
8484include_recipe "gitlab::users"
8585
86+ # Recipe for gitlab-backup-cli tool
87+ include_recipe "gitlab::gitlab-backup-cli"
88+
8689include_recipe "gitlab::gitlab-rails" if node [ 'gitlab' ] [ 'gitlab_rails' ] [ 'enable' ]
8790
8891include_recipe "gitlab::selinux"
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright:: Copyright (c) 2024 GitLab Inc.
3+ # License:: Apache License, Version 2.0
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ install_dir = node [ 'package' ] [ 'install-dir' ]
18+ gitlab_backup_cli_config_file = "#{ install_dir } /etc/gitlab-backup-cli-config.yml"
19+
20+ template gitlab_backup_cli_config_file do
21+ owner 'root'
22+ group 'root'
23+ mode '0644'
24+ source 'gitlab-backup-cli-config.yml.erb'
25+ sensitive true
26+ end
Original file line number Diff line number Diff line change 1+ <% gitlab_rails_dir = node['gitlab']['gitlab_rails']['dir'] %>
2+ <% gitlab_rails_etc_dir = File.join(gitlab_rails_dir, 'etc') %>
3+
4+ version: 1
5+ installation_type: "omnibus"
6+ gitlab:
7+ config_path: <%= File.join(gitlab_rails_etc_dir, 'gitlab.yml') %>
8+ database:
9+ config_path: <%= File.join(gitlab_rails_etc_dir, 'database.yml') %>
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ usr_bin_symlinks=(
1212 " ${DEST_DIR} /bin/gitlab-geo-psql"
1313 " ${DEST_DIR} /bin/gitlab-backup"
1414 " ${DEST_DIR} /bin/gitlab-redis-cli"
15+ " ${DEST_DIR} /bin/gitlab-backup-cli"
1516)
1617
1718error_exit ()
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright:: Copyright (c) 2024 GitLab Inc.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ #
16+
17+ require 'chef_helper'
18+
19+ RSpec . describe 'gitlab::gitlab-backup-cli' do
20+ let ( :chef_runner ) do
21+ ChefSpec ::SoloRunner . new do |node |
22+ node . normal [ 'package' ] [ 'install-dir' ] = '/opt/gitlab'
23+ end
24+ end
25+
26+ let ( :chef_run ) do
27+ chef_runner . converge ( 'gitlab::default' )
28+ end
29+
30+ let ( :template_path ) { '/opt/gitlab/etc/gitlab-backup-cli-config.yml' }
31+
32+ before do
33+ allow ( Gitlab ) . to receive ( :[] ) . and_call_original
34+ end
35+
36+ it 'creates gitlab-backup-cli-config.yml template' do
37+ expect ( chef_run ) . to create_template ( template_path ) . with (
38+ owner : 'root' ,
39+ group : 'root' ,
40+ mode : '0644' ,
41+ source : 'gitlab-backup-cli-config.yml.erb' ,
42+ sensitive : true
43+ )
44+ end
45+ end
You can’t perform that action at this time.
0 commit comments