Skip to content

Instantly share code, notes, and snippets.

@ynott
Last active July 8, 2018 11:59
Show Gist options
  • Save ynott/3010e4f85ae4f7d185301c88a552e30e to your computer and use it in GitHub Desktop.
Save ynott/3010e4f85ae4f7d185301c88a552e30e to your computer and use it in GitHub Desktop.
GitLab CEで Zeroダウンタイムアップグレードを試す ref: https://qiita.com/ynott/items/77e6f287a44bc1d6e797
sudo gitlab-ctl hup unicorn
sudo gitlab-ctl hup sidekiq
GitLab 10.8.3 (564c342)
GitLab Shell 7.1.2
GitLab Workhorse v4.2.1
GitLab API v4
Ruby 2.3.7p456
Rails 4.2.10
postgresql 9.6.8
Gitaly Servers
@ynott
Copy link
Author

ynott commented Jun 28, 2018

#!/bin/bash
export LANG=en_US.UTF-8

# Check update
sudo apt update

# Get versions(Ret Value:11.0.1-ce.0 11.0.2-ce.0)
VERSIONS_OLDNEW=$(apt-cache policy gitlab-ce | grep -1 Installed | sed -r 's/(^  )//' | grep -v 'gitlab-ce:')
VERSION_OLD=$(echo $VERSIONS_OLDNEW | sed -r 's/Installed: (.*?) Candidate: .*/\1/g')
VERSION_NEW=$(echo $VERSIONS_OLDNEW | sed -r 's/Installed: .* Candidate: (.*?)/\1/g')

DIFF=$(cmp -bl <(echo "$VERSION_OLD" ) <(echo "$VERSION_NEW" )|tr -d ' ')
DIFF_POS=${DIFF:0:1}

# check if you can upgrade
if [ "$VERSION_OLD" = "$VERSION_NEW" ];
then
   echo "GitLab CE Version is not update, exit"
   exit 0;
fi

# check version update major or not ( less than 2 is Major Version Up )
if [ $(($DIFF_POS)) -gt 2  ];
then
  echo "Installed Version:$VERSION_OLD"
  echo "Candidate Version:$VERSION_NEW"
  sudo apt-get install gitlab-ce
  SKIP_POST_DEPLOYMENT_MIGRATIONS=true sudo gitlab-ctl reconfigure
  sudo gitlab-rake db:migrate
  sudo gitlab-ctl hup unicorn
  sudo gitlab-ctl hup sidekiq
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment