]> git.pld-linux.org Git - packages/gitlab-ce.git/commitdiff
setup db backup and db upgrade on package upgrade gitlab-ce-8.8.1-0.34
authorElan Ruusamäe <glen@delfi.ee>
Thu, 26 May 2016 20:47:51 +0000 (23:47 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 26 May 2016 20:47:51 +0000 (23:47 +0300)
gitlab-ce.spec
gitlab-ctl.sh

index 8fa06dd02a218d8a9cc31991bb9f73701fd279b6..5d6cf4ff21788e68564ebef6c52e4b05d021a132 100644 (file)
@@ -202,6 +202,12 @@ install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
 %clean
 rm -rf "$RPM_BUILD_ROOT"
 
+%pre
+if [ "$2" = "2" ]; then
+       # Looks like an RPM upgrade
+       gitlab-ctl preinst
+fi
+
 %post
 /sbin/chkconfig --add gitlab-sidekiq
 /sbin/chkconfig --add gitlab-unicorn
@@ -228,6 +234,12 @@ else
        systemctl -q try-start gitlab-sidekiq || :
 fi
 
+%posttrans
+if [ "$1" = "0" ]; then
+       # Looks like an RPM upgrade
+       gitlab-ctl posttrans
+fi
+
 %preun
 if [ "$1" = "0" ]; then
        %service -q gitlab-sidekiq stop
index 2b353537cc689c2748a0b01b65bdf8116560ebcc..3307770bd6abf56c5e1b2e1aacc84053ea6b4bb3 100755 (executable)
@@ -11,10 +11,30 @@ die() {
        exit 1
 }
 
+# Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
+upgrade() {
+       gitlab-rake db:migrate "$@"
+}
+
+# GitLab | Create a backup of the GitLab system
+backup() {
+       gitlab-rake gitlab:backup:create "$@"
+}
+
+# http://docs.gitlab.com/ce/administration/restart_gitlab.html#installations-from-source
+restart() {
+       :
+}
+
 # Run backup before package upgrade
 # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/config/templates/package-scripts/preinst.erb#L10
-backup_before_upgrade() {
-       if ! gitlab-rake gitlab:backup:create SKIP=repositories,uploads,builds,artifacts,lfs,registry; then
+preinst() {
+       if [ -f $auto_migrations_skip_file ]; then
+               echo >&2 "Found $auto_migrations_skip_file, skipping auto backup..."
+               return
+       fi
+
+       if ! backup SKIP=repositories,uploads,builds,artifacts,lfs,registry; then
                cat >&2 <<-EOF
 
                Backup failed! If you want to skip this backup, run the following command and try again:
@@ -27,19 +47,9 @@ backup_before_upgrade() {
 }
 
 # Run migrations after a package upgrade
+# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/config/templates/package-scripts/posttrans.erb
 # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/files/gitlab-ctl-commands/upgrade.rb
-upgrade() {
-       gitlab-rake db:migrate
-}
-
-# Run migrations after a package upgrade
-pkg_upgrade() {
-       if [ -f $auto_migrations_skip_file ]; then
-               echo >&2 "Found $auto_migrations_skip_file, exiting..."
-               return
-       fi
-
-       backup_before_upgrade
+posttrans() {
        upgrade
 
        cat >&2 <<-EOF
@@ -48,17 +58,17 @@ pkg_upgrade() {
                If you need to roll back to the previous version you can
                use the database backup made during the upgrade (scroll up for the filename).
        EOF
-
-}
-
-# http://docs.gitlab.com/ce/administration/restart_gitlab.html#installations-from-source
-restart() {
-       :
 }
 
 case "$1" in
-pkg-upgrade)
-       pkg_upgrade
+preinst)
+       preinst
+       ;;
+posttrans)
+       posttrans
+       ;;
+backup)
+       backup "$@"
        ;;
 upgrade)
        upgrade
This page took 0.093082 seconds and 4 git commands to generate.