Commit 9a6eb96e5d59b7c0ec83cbc7463450ca8181d3d0
Exists in
6-6-stable-ee
and in
1 other branch
Merge branch 'master' of gitlab.com:gitlab-org/omnibus-gitlab into 6-6-stable
Conflicts: config/software/gitlab-rails.rb
Showing
6 changed files
with
38 additions
and
134 deletions
Show diff stats
README.md
| ... | ... | @@ -74,12 +74,46 @@ external_url "http://gitlab.example.com" |
| 74 | 74 | |
| 75 | 75 | Run `sudo gitlab-ctl reconfigure` for the change to take effect. |
| 76 | 76 | |
| 77 | +### Creating an application backup | |
| 78 | + | |
| 79 | +To create a backup of your repositories and GitLab metadata, run the following command. | |
| 80 | + | |
| 81 | +```shell | |
| 82 | +sudo gitlab-rake gitlab:backup:create | |
| 83 | +``` | |
| 84 | + | |
| 85 | +This will store a tar file in `/var/opt/gitlab/backups`. The filename will look like | |
| 86 | +`1393513186_gitlab_backup.tar`, where 1393513186 is a timestamp. | |
| 87 | + | |
| 88 | +### Restoring an application backup | |
| 89 | + | |
| 90 | +We will assume that you have installed GitLab from an omnibus package and run | |
| 91 | +`sudo gitlab-ctl reconfigure` at least once. | |
| 92 | + | |
| 93 | +First make sure your backup tar file is in `/var/opt/gitlab/backups`. | |
| 94 | + | |
| 95 | +```shell | |
| 96 | +sudo cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/ | |
| 97 | +``` | |
| 98 | + | |
| 99 | +Next, restore the backup by running the restore command. You need to specify the | |
| 100 | +timestamp of the backup you are restoring. | |
| 101 | + | |
| 102 | +```shell | |
| 103 | +# This command will overwrite the contents of your GitLab database! | |
| 104 | +sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186 | |
| 105 | +``` | |
| 106 | + | |
| 107 | +If there is a GitLab version mismatch between your backup tar file and the installed | |
| 108 | +version of GitLab, the restore command will abort with an error. Install a package for | |
| 109 | +the [required version](https://www.gitlab.com/downloads/archives/) and try again. | |
| 110 | + | |
| 77 | 111 | ### Invoking Rake tasks |
| 78 | 112 | |
| 79 | 113 | To invoke a GitLab Rake task, use `gitlab-rake`. For example: |
| 80 | 114 | |
| 81 | 115 | ```shell |
| 82 | -sudo gitlab-rake gitlab:backup:create | |
| 116 | +sudo gitlab-rake gitlab:check | |
| 83 | 117 | ``` |
| 84 | 118 | |
| 85 | 119 | Contrary to with a traditional GitLab installation, there is no need to change | ... | ... |
config/patches/gitlab-shell/create_hooks.patch
| ... | ... | @@ -1,126 +0,0 @@ |
| 1 | -diff --git a/bin/create-hooks b/bin/create-hooks | |
| 2 | -new file mode 100755 | |
| 3 | -index 0000000..d6f07c7 | |
| 4 | ---- /dev/null | |
| 5 | -+++ b/bin/create-hooks | |
| 6 | -@@ -0,0 +1,12 @@ | |
| 7 | -+#!/usr/bin/env ruby | |
| 8 | -+ | |
| 9 | -+# Recreate GitLab hooks in the Git repositories managed by GitLab. | |
| 10 | -+# | |
| 11 | -+# This script is used when restoring a GitLab backup. | |
| 12 | -+ | |
| 13 | -+require_relative '../lib/gitlab_init' | |
| 14 | -+require File.join(ROOT_PATH, 'lib', 'gitlab_projects') | |
| 15 | -+ | |
| 16 | -+Dir["#{GitlabConfig.new.repos_path}/*/*.git"].each do |repo| | |
| 17 | -+ GitlabProjects.create_hooks(repo) | |
| 18 | -+end | |
| 19 | -diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb | |
| 20 | -index fec204c..b3ff372 100644 | |
| 21 | ---- a/lib/gitlab_projects.rb | |
| 22 | -+++ b/lib/gitlab_projects.rb | |
| 23 | -@@ -42,6 +42,12 @@ class GitlabProjects | |
| 24 | - end | |
| 25 | - end | |
| 26 | - | |
| 27 | -+ def self.create_hooks(path) | |
| 28 | -+ hook = File.join(path, 'hooks', 'update') | |
| 29 | -+ File.delete(hook) if File.exists?(hook) | |
| 30 | -+ File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), hook) | |
| 31 | -+ end | |
| 32 | -+ | |
| 33 | - protected | |
| 34 | - | |
| 35 | - def create_branch | |
| 36 | -@@ -74,13 +80,7 @@ class GitlabProjects | |
| 37 | - $logger.info "Adding project #{@project_name} at <#{full_path}>." | |
| 38 | - FileUtils.mkdir_p(full_path, mode: 0770) | |
| 39 | - cmd = %W(git --git-dir=#{full_path} init --bare) | |
| 40 | -- system(*cmd) && create_hooks(full_path) | |
| 41 | -- end | |
| 42 | -- | |
| 43 | -- def create_hooks(path) | |
| 44 | -- hook = File.join(path, 'hooks', 'update') | |
| 45 | -- File.delete(hook) if File.exists?(hook) | |
| 46 | -- File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), hook) | |
| 47 | -+ system(*cmd) && self.class.create_hooks(full_path) | |
| 48 | - end | |
| 49 | - | |
| 50 | - def rm_project | |
| 51 | -@@ -94,7 +94,7 @@ class GitlabProjects | |
| 52 | - @source = ARGV.shift | |
| 53 | - $logger.info "Importing project #{@project_name} from <#{@source}> to <#{full_path}>." | |
| 54 | - cmd = %W(git clone --bare -- #{@source} #{full_path}) | |
| 55 | -- system(*cmd) && create_hooks(full_path) | |
| 56 | -+ system(*cmd) && self.class.create_hooks(full_path) | |
| 57 | - end | |
| 58 | - | |
| 59 | - # Move repository from one directory to another | |
| 60 | -@@ -156,7 +156,7 @@ class GitlabProjects | |
| 61 | - | |
| 62 | - $logger.info "Forking project from <#{full_path}> to <#{full_destination_path}>." | |
| 63 | - cmd = %W(git clone --bare -- #{full_path} #{full_destination_path}) | |
| 64 | -- system(*cmd) && create_hooks(full_destination_path) | |
| 65 | -+ system(*cmd) && self.class.create_hooks(full_destination_path) | |
| 66 | - end | |
| 67 | - | |
| 68 | - def update_head | |
| 69 | -diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb | |
| 70 | -index bbe27e2..4341ca5 100644 | |
| 71 | ---- a/spec/gitlab_projects_spec.rb | |
| 72 | -+++ b/spec/gitlab_projects_spec.rb | |
| 73 | -@@ -95,7 +95,7 @@ describe GitlabProjects do | |
| 74 | - | |
| 75 | - it "should create a directory" do | |
| 76 | - gl_projects.stub(system: true) | |
| 77 | -- gl_projects.stub(create_hooks: true) | |
| 78 | -+ GitlabProjects.stub(create_hooks: true) | |
| 79 | - gl_projects.exec | |
| 80 | - File.exists?(tmp_repo_path).should be_true | |
| 81 | - end | |
| 82 | -@@ -103,7 +103,7 @@ describe GitlabProjects do | |
| 83 | - it "should receive valid cmd" do | |
| 84 | - valid_cmd = ['git', "--git-dir=#{tmp_repo_path}", 'init', '--bare'] | |
| 85 | - gl_projects.should_receive(:system).with(*valid_cmd).and_return(true) | |
| 86 | -- gl_projects.should_receive(:create_hooks).with(tmp_repo_path) | |
| 87 | -+ GitlabProjects.should_receive(:create_hooks).with(tmp_repo_path) | |
| 88 | - gl_projects.exec | |
| 89 | - end | |
| 90 | - | |
| 91 | -diff --git a/support/rewrite-hooks.sh b/support/rewrite-hooks.sh | |
| 92 | -index 3c96b6f..585eaeb 100755 | |
| 93 | ---- a/support/rewrite-hooks.sh | |
| 94 | -+++ b/support/rewrite-hooks.sh | |
| 95 | -@@ -1,28 +1,5 @@ | |
| 96 | - #!/bin/bash | |
| 97 | -+# This script is deprecated. Use bin/create-hooks instead. | |
| 98 | - | |
| 99 | --# $1 is an optional argument specifying the location of the repositories directory. | |
| 100 | --# Defaults to /home/git/repositories if not provided | |
| 101 | -- | |
| 102 | --home_dir="/home/git" | |
| 103 | --src=${1:-"$home_dir/repositories"} | |
| 104 | -- | |
| 105 | --function create_link_in { | |
| 106 | -- ln -s -f "$home_dir/gitlab-shell/hooks/update" "$1/hooks/update" | |
| 107 | --} | |
| 108 | -- | |
| 109 | --for dir in `ls "$src/"` | |
| 110 | --do | |
| 111 | -- if [ -d "$src/$dir" ]; then | |
| 112 | -- if [[ "$dir" =~ ^.*\.git$ ]] | |
| 113 | -- then | |
| 114 | -- create_link_in "$src/$dir" | |
| 115 | -- else | |
| 116 | -- for subdir in `ls "$src/$dir/"` | |
| 117 | -- do | |
| 118 | -- if [ -d "$src/$dir/$subdir" ] && [[ "$subdir" =~ ^.*\.git$ ]]; then | |
| 119 | -- create_link_in "$src/$dir/$subdir" | |
| 120 | -- fi | |
| 121 | -- done | |
| 122 | -- fi | |
| 123 | -- fi | |
| 124 | --done | |
| 125 | -+gitlab_shell_dir="$(cd $(dirname $0) && pwd)/.." | |
| 126 | -+exec ${gitlab_shell_dir}/bin/create-hooks |
config/software/gitlab-shell.rb
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | # |
| 18 | 18 | |
| 19 | 19 | name "gitlab-shell" |
| 20 | -version "v1.8.0" | |
| 20 | +version "79bceae69cb5750d6567b223597999bfa91cb3b9" | |
| 21 | 21 | |
| 22 | 22 | dependency "ruby" |
| 23 | 23 | dependency "rsync" |
| ... | ... | @@ -25,9 +25,6 @@ dependency "rsync" |
| 25 | 25 | source :git => "https://gitlab.com/gitlab-org/gitlab-shell.git" |
| 26 | 26 | |
| 27 | 27 | build do |
| 28 | - # patch gitlab-shell 1.8.0 to correctly create hooks during backup restore | |
| 29 | - patch :source => "create_hooks.patch" | |
| 30 | - | |
| 31 | 28 | command "mkdir -p #{install_dir}/embedded/service/gitlab-shell" |
| 32 | 29 | command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/gitlab-shell/" |
| 33 | 30 | block do | ... | ... |
files/gitlab-cookbooks/gitlab/attributes/default.rb
| ... | ... | @@ -87,7 +87,7 @@ default['gitlab']['gitlab-rails']['ldap_bind_dn'] = "_the_full_dn_of_the_user_yo |
| 87 | 87 | default['gitlab']['gitlab-rails']['ldap_password'] = "_the_password_of_the_bind_user" |
| 88 | 88 | default['gitlab']['gitlab-rails']['ldap_allow_username_or_email_login'] = true |
| 89 | 89 | default['gitlab']['gitlab-rails']['satellites_path'] = "/var/opt/gitlab/git-data/gitlab-satellites" |
| 90 | -default['gitlab']['gitlab-rails']['backup_path'] = "tmp/backups" | |
| 90 | +default['gitlab']['gitlab-rails']['backup_path'] = "/var/opt/gitlab/backups" | |
| 91 | 91 | default['gitlab']['gitlab-rails']['gitlab_shell_path'] = "/opt/gitlab/embedded/service/gitlab-shell/" |
| 92 | 92 | default['gitlab']['gitlab-rails']['gitlab_shell_repos_path'] = "/var/opt/gitlab/git-data/repositories" |
| 93 | 93 | default['gitlab']['gitlab-rails']['gitlab_shell_hooks_path'] = "/opt/gitlab/embedded/service/gitlab-shell/hooks/" | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb
| ... | ... | @@ -30,6 +30,7 @@ gitlab_rails_log_dir = node['gitlab']['gitlab-rails']['log_directory'] |
| 30 | 30 | gitlab_rails_working_dir, |
| 31 | 31 | gitlab_rails_tmp_dir, |
| 32 | 32 | gitlab_rails_public_uploads_dir, |
| 33 | + node['gitlab']['gitlab-rails']['backup_path'], | |
| 33 | 34 | gitlab_rails_log_dir |
| 34 | 35 | ].each do |dir_name| |
| 35 | 36 | directory dir_name do | ... | ... |
package-scripts/gitlab/postinst
| ... | ... | @@ -22,7 +22,5 @@ echo "You can configure GitLab for your system by running the following command: |
| 22 | 22 | echo |
| 23 | 23 | echo "sudo gitlab-ctl reconfigure" |
| 24 | 24 | echo |
| 25 | -echo WARNING: this is an unstable release. This installer should not be used in production. | |
| 26 | -echo | |
| 27 | 25 | |
| 28 | 26 | exit 0 | ... | ... |