Skip to content
Snippets Groups Projects
Commit 9a6eb96e authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Merge branch 'master' of gitlab.com:gitlab-org/omnibus-gitlab into 6-6-stable

Conflicts:
	config/software/gitlab-rails.rb
parents db9a6013 c2225cc5
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -74,12 +74,46 @@ external_url "http://gitlab.example.com"
 
Run `sudo gitlab-ctl reconfigure` for the change to take effect.
 
### Creating an application backup
To create a backup of your repositories and GitLab metadata, run the following command.
```shell
sudo gitlab-rake gitlab:backup:create
```
This will store a tar file in `/var/opt/gitlab/backups`. The filename will look like
`1393513186_gitlab_backup.tar`, where 1393513186 is a timestamp.
### Restoring an application backup
We will assume that you have installed GitLab from an omnibus package and run
`sudo gitlab-ctl reconfigure` at least once.
First make sure your backup tar file is in `/var/opt/gitlab/backups`.
```shell
sudo cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/
```
Next, restore the backup by running the restore command. You need to specify the
timestamp of the backup you are restoring.
```shell
# This command will overwrite the contents of your GitLab database!
sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186
```
If there is a GitLab version mismatch between your backup tar file and the installed
version of GitLab, the restore command will abort with an error. Install a package for
the [required version](https://www.gitlab.com/downloads/archives/) and try again.
### Invoking Rake tasks
 
To invoke a GitLab Rake task, use `gitlab-rake`. For example:
 
```shell
sudo gitlab-rake gitlab:backup:create
sudo gitlab-rake gitlab:check
```
 
Contrary to with a traditional GitLab installation, there is no need to change
Loading
Loading
diff --git a/bin/create-hooks b/bin/create-hooks
new file mode 100755
index 0000000..d6f07c7
--- /dev/null
+++ b/bin/create-hooks
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+
+# Recreate GitLab hooks in the Git repositories managed by GitLab.
+#
+# This script is used when restoring a GitLab backup.
+
+require_relative '../lib/gitlab_init'
+require File.join(ROOT_PATH, 'lib', 'gitlab_projects')
+
+Dir["#{GitlabConfig.new.repos_path}/*/*.git"].each do |repo|
+ GitlabProjects.create_hooks(repo)
+end
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index fec204c..b3ff372 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -42,6 +42,12 @@ class GitlabProjects
end
end
+ def self.create_hooks(path)
+ hook = File.join(path, 'hooks', 'update')
+ File.delete(hook) if File.exists?(hook)
+ File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), hook)
+ end
+
protected
def create_branch
@@ -74,13 +80,7 @@ class GitlabProjects
$logger.info "Adding project #{@project_name} at <#{full_path}>."
FileUtils.mkdir_p(full_path, mode: 0770)
cmd = %W(git --git-dir=#{full_path} init --bare)
- system(*cmd) && create_hooks(full_path)
- end
-
- def create_hooks(path)
- hook = File.join(path, 'hooks', 'update')
- File.delete(hook) if File.exists?(hook)
- File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), hook)
+ system(*cmd) && self.class.create_hooks(full_path)
end
def rm_project
@@ -94,7 +94,7 @@ class GitlabProjects
@source = ARGV.shift
$logger.info "Importing project #{@project_name} from <#{@source}> to <#{full_path}>."
cmd = %W(git clone --bare -- #{@source} #{full_path})
- system(*cmd) && create_hooks(full_path)
+ system(*cmd) && self.class.create_hooks(full_path)
end
# Move repository from one directory to another
@@ -156,7 +156,7 @@ class GitlabProjects
$logger.info "Forking project from <#{full_path}> to <#{full_destination_path}>."
cmd = %W(git clone --bare -- #{full_path} #{full_destination_path})
- system(*cmd) && create_hooks(full_destination_path)
+ system(*cmd) && self.class.create_hooks(full_destination_path)
end
def update_head
diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb
index bbe27e2..4341ca5 100644
--- a/spec/gitlab_projects_spec.rb
+++ b/spec/gitlab_projects_spec.rb
@@ -95,7 +95,7 @@ describe GitlabProjects do
it "should create a directory" do
gl_projects.stub(system: true)
- gl_projects.stub(create_hooks: true)
+ GitlabProjects.stub(create_hooks: true)
gl_projects.exec
File.exists?(tmp_repo_path).should be_true
end
@@ -103,7 +103,7 @@ describe GitlabProjects do
it "should receive valid cmd" do
valid_cmd = ['git', "--git-dir=#{tmp_repo_path}", 'init', '--bare']
gl_projects.should_receive(:system).with(*valid_cmd).and_return(true)
- gl_projects.should_receive(:create_hooks).with(tmp_repo_path)
+ GitlabProjects.should_receive(:create_hooks).with(tmp_repo_path)
gl_projects.exec
end
diff --git a/support/rewrite-hooks.sh b/support/rewrite-hooks.sh
index 3c96b6f..585eaeb 100755
--- a/support/rewrite-hooks.sh
+++ b/support/rewrite-hooks.sh
@@ -1,28 +1,5 @@
#!/bin/bash
+# This script is deprecated. Use bin/create-hooks instead.
-# $1 is an optional argument specifying the location of the repositories directory.
-# Defaults to /home/git/repositories if not provided
-
-home_dir="/home/git"
-src=${1:-"$home_dir/repositories"}
-
-function create_link_in {
- ln -s -f "$home_dir/gitlab-shell/hooks/update" "$1/hooks/update"
-}
-
-for dir in `ls "$src/"`
-do
- if [ -d "$src/$dir" ]; then
- if [[ "$dir" =~ ^.*\.git$ ]]
- then
- create_link_in "$src/$dir"
- else
- for subdir in `ls "$src/$dir/"`
- do
- if [ -d "$src/$dir/$subdir" ] && [[ "$subdir" =~ ^.*\.git$ ]]; then
- create_link_in "$src/$dir/$subdir"
- fi
- done
- fi
- fi
-done
+gitlab_shell_dir="$(cd $(dirname $0) && pwd)/.."
+exec ${gitlab_shell_dir}/bin/create-hooks
Loading
Loading
@@ -17,7 +17,7 @@
#
 
name "gitlab-shell"
version "v1.8.0"
version "79bceae69cb5750d6567b223597999bfa91cb3b9"
 
dependency "ruby"
dependency "rsync"
Loading
Loading
@@ -25,9 +25,6 @@ dependency "rsync"
source :git => "https://gitlab.com/gitlab-org/gitlab-shell.git"
 
build do
# patch gitlab-shell 1.8.0 to correctly create hooks during backup restore
patch :source => "create_hooks.patch"
command "mkdir -p #{install_dir}/embedded/service/gitlab-shell"
command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/gitlab-shell/"
block do
Loading
Loading
Loading
Loading
@@ -87,7 +87,7 @@ default['gitlab']['gitlab-rails']['ldap_bind_dn'] = "_the_full_dn_of_the_user_yo
default['gitlab']['gitlab-rails']['ldap_password'] = "_the_password_of_the_bind_user"
default['gitlab']['gitlab-rails']['ldap_allow_username_or_email_login'] = true
default['gitlab']['gitlab-rails']['satellites_path'] = "/var/opt/gitlab/git-data/gitlab-satellites"
default['gitlab']['gitlab-rails']['backup_path'] = "tmp/backups"
default['gitlab']['gitlab-rails']['backup_path'] = "/var/opt/gitlab/backups"
default['gitlab']['gitlab-rails']['gitlab_shell_path'] = "/opt/gitlab/embedded/service/gitlab-shell/"
default['gitlab']['gitlab-rails']['gitlab_shell_repos_path'] = "/var/opt/gitlab/git-data/repositories"
default['gitlab']['gitlab-rails']['gitlab_shell_hooks_path'] = "/opt/gitlab/embedded/service/gitlab-shell/hooks/"
Loading
Loading
Loading
Loading
@@ -30,6 +30,7 @@ gitlab_rails_log_dir = node['gitlab']['gitlab-rails']['log_directory']
gitlab_rails_working_dir,
gitlab_rails_tmp_dir,
gitlab_rails_public_uploads_dir,
node['gitlab']['gitlab-rails']['backup_path'],
gitlab_rails_log_dir
].each do |dir_name|
directory dir_name do
Loading
Loading
Loading
Loading
@@ -22,7 +22,5 @@ echo "You can configure GitLab for your system by running the following command:
echo
echo "sudo gitlab-ctl reconfigure"
echo
echo WARNING: this is an unstable release. This installer should not be used in production.
echo
 
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment