From 330f5492cb3bcda630be4f8cd931085746a9f490 Mon Sep 17 00:00:00 2001 From: David Carlos Date: Thu, 28 Apr 2016 18:26:26 -0300 Subject: [PATCH] Add restore step --- provision.sh | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/provision.sh b/provision.sh index 42a9302..39e427f 100755 --- a/provision.sh +++ b/provision.sh @@ -17,7 +17,11 @@ yum -y install gitlab # Coisas estranhas: # # Installing : gitlab-shell-2.4.0-5.1.noarch +### Aparentemente, tanto as receitas quanto os specs, esperam que exista um usuário git +### criado nas máquinaso usuário git # id: git: no such user + +### Isso não é uma coisa estranha, é o output padrão quando se instala o gitlab-shell # mkdir -p /var/lib/gitlab-shell/repositories/: OK # mkdir -p /var/lib/gitlab-shell/.ssh: OK # chmod 700 /var/lib/gitlab-shell/.ssh: OK @@ -25,20 +29,27 @@ yum -y install gitlab # chmod 600 /var/lib/gitlab-shell/.ssh/authorized_keys: OK # chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/: OK # find /var/lib/gitlab-shell/repositories/ -type d -exec chmod g+s {} ;: OK + # # # -# Installing : gitlab-7.6.2-13.2.noarch +# Installing : gitlab-7.6.2-13.2.noarch +### Isso é um erro no pacote do gitlab-7.6. Ele cria um link simbólico apontado +### para /var/lib/gitlab-assets, e depois tenta dar um chown, mas a pasta ainda não existe. +### Podemos fazer esse fix. # chown: cannot access ‘/var/lib/gitlab-assets’: No such file or directory + # Redirecting to /bin/systemctl start redis.service # rake aborted! + +### No pacote do gitlab 8.5 eu simplesmente dei permissão git:git pra pasta /usr/lib/gitlab # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret -# +# # Tasks: TOP => db:migrate:status => environment # (See full trace by running task with --trace) # rake aborted! # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret -# +# # Tasks: TOP => gitlab:setup => environment # (See full trace by running task with --trace) # I, [2016-04-25T22:50:47.389656 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_32-7d94ec26bfa902d9573dac174421752a.png @@ -60,18 +71,18 @@ sudo -u postgres createuser git cd /usr/lib/gitlab sudo -u git bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done -sed -i 's,http://localhost:8080/,http://localhost:8080/gitlab,' /etc/gitlab-shell/config.yml +sed -i 's,http://localhost:8080/,http://localhost:8080/gitlab,' /etc/gitlab-shell/config.yml echo 'production: redis://localhost:6379' > /usr/lib/gitlab/config/resque.yml sed -i 's,localhost,localhost\n relative_url_root: /gitlab,' /etc/gitlab/gitlab.yml cat << EOF > /usr/lib/gitlab/config/initializers/gitlab_shell_secret_token.rb Gitlab::Application.configure do - config.relative_url_root = "/gitlab" + config.relative_url_root = "/gitlab" end EOF -cat << EOF > /etc/nginx/conf.d/gitlab.conf +cat << EOF > /etc/nginx/conf.d/gitlab.conf upstream gitlab { server 0.0.0.0:8080 fail_timeout=10s; } @@ -120,8 +131,23 @@ cd /usr/lib/gitlab && sudo -u git bundle exec rake assets:precompile RAILS_ENV=production systemctl enable gitlab -systemctl start gitlab - +systemctl start gitlab + +##### restore backup + +backup=$(echo *_backup.tar) +if [[ -e /vagrant/$backup ]]; then + printf "####################################################" + printf "Restaurando backup" + systemctl stop gitlab + sleep 3 + printf "Movendo backup para diretório correto" + install -D -m 755 -o git -g git /vagrant/$backup /var/lib/gitlab/backups + ### O task do gitlab espera uma resposta via bash, não sei se tem como mandarmos essa resposta via bash. + # (cd /usr/lib/gitlab && sudo -u git bundle exec rake gitlab:backup:restore RAILS_ENV=production) +else + printf "Backup não encontrado" +fi # bootstrap / provision -- libgit2 0.21.2