sameersbn / docker-gitlab

Dockerized GitLab
http://www.damagehead.com/docker-gitlab/
MIT License
7.88k stars 2.14k forks source link

Restore doesnt work - app:rake not found and Docker compose restore asks interactive question #2280

Closed danobot closed 3 years ago

danobot commented 3 years ago

Connecting to container like this:

docker exec -it gitlab_gitlab_1 /bin/bash

The running this command inside:

root@fb8e428da132:/home/git/gitlab# app:rake gitlab:backup:restore BACKUP=1609163751_2020_12_28_12.7.7
bash: app:rake: command not found

When i call it in docker compose method it asks an interactive question which kills the process.

gitlab:
    restart: always
    image: sameersbn/gitlab:12.7.7
    command:  "app:rake gitlab:backup:restore BACKUP=1609163751_2020_12_28_12.7.7"

Logs:

gitlab_1      | 2021-01-01T11:44:21.936596286Z Running raketask gitlab:backup:restore...
postgresql_1  | 2021-01-01T11:44:35.014397932Z 2021-01-01 11:44:35.014 UTC [245] ERROR:  relation "feature_gates" does not exist at character 566
postgresql_1  | 2021-01-01T11:44:35.014416011Z 2021-01-01 11:44:35.014 UTC [245] STATEMENT:                SELECT a.attname, format_type(a.atttypid, a.atttypmod),
postgresql_1  | 2021-01-01T11:44:35.014421330Z                       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
postgresql_1  | 2021-01-01T11:44:35.014426469Z                       c.collname, col_description(a.attrelid, a.attnum) AS comment
postgresql_1  | 2021-01-01T11:44:35.014431096Z                  FROM pg_attribute a
postgresql_1  | 2021-01-01T11:44:35.014436129Z                  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
postgresql_1  | 2021-01-01T11:44:35.014440913Z                  LEFT JOIN pg_type t ON a.atttypid = t.oid
postgresql_1  | 2021-01-01T11:44:35.014445150Z                  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
postgresql_1  | 2021-01-01T11:44:35.014448470Z                 WHERE a.attrelid = '"feature_gates"'::regclass
postgresql_1  | 2021-01-01T11:44:35.014451493Z                   AND a.attnum > 0 AND NOT a.attisdropped
postgresql_1  | 2021-01-01T11:44:35.014454346Z                 ORDER BY a.attnum
postgresql_1  | 2021-01-01T11:44:35.014457387Z 
postgresql_1  | 2021-01-01T11:44:35.313745642Z 2021-01-01 11:44:35.313 UTC [247] ERROR:  relation "feature_gates" does not exist at character 566
postgresql_1  | 2021-01-01T11:44:35.313766273Z 2021-01-01 11:44:35.313 UTC [247] STATEMENT:                SELECT a.attname, format_type(a.atttypid, a.atttypmod),
postgresql_1  | 2021-01-01T11:44:35.313772846Z                       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
postgresql_1  | 2021-01-01T11:44:35.313777569Z                       c.collname, col_description(a.attrelid, a.attnum) AS comment
postgresql_1  | 2021-01-01T11:44:35.313781957Z                  FROM pg_attribute a
postgresql_1  | 2021-01-01T11:44:35.313786133Z                  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
postgresql_1  | 2021-01-01T11:44:35.313790974Z                  LEFT JOIN pg_type t ON a.atttypid = t.oid
postgresql_1  | 2021-01-01T11:44:35.313795737Z                  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
postgresql_1  | 2021-01-01T11:44:35.313801162Z                 WHERE a.attrelid = '"feature_gates"'::regclass
postgresql_1  | 2021-01-01T11:44:35.313805531Z                   AND a.attnum > 0 AND NOT a.attisdropped
postgresql_1  | 2021-01-01T11:44:35.313809681Z                 ORDER BY a.attnum
postgresql_1  | 2021-01-01T11:44:35.313813805Z 
gitlab_1      | 2021-01-01T11:44:42.991672154Z rake aborted!
gitlab_1      | 2021-01-01T11:44:42.991702148Z NoMethodError: undefined method `chomp' for nil:NilClass
gitlab_1      | 2021-01-01T11:44:42.991711267Z /home/git/gitlab/lib/gitlab/task_helpers.rb:62:in `prompt'
gitlab_1      | 2021-01-01T11:44:42.991714808Z /home/git/gitlab/lib/gitlab/task_helpers.rb:27:in `ask_to_continue'
gitlab_1      | 2021-01-01T11:44:42.991719193Z /home/git/gitlab/lib/tasks/gitlab/backup.rake:48:in `block (3 levels) in <top (required)>'
gitlab_1      | 2021-01-01T11:44:42.991722374Z /home/git/gitlab/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
gitlab_1      | 2021-01-01T11:44:42.991725111Z Tasks: TOP => gitlab:backup:restore
gitlab_1      | 2021-01-01T11:44:42.991727737Z (See full trace by running task with --trace)
gitlab_1      | 2021-01-01T11:44:43.005928415Z Unpacking backup ... done
gitlab_1      | 2021-01-01T11:44:43.005955855Z Before restoring the database, we will remove all existing
gitlab_1      | 2021-01-01T11:44:43.005960677Z tables to avoid future upgrade problems. Be aware that if you have
gitlab_1      | 2021-01-01T11:44:43.005964758Z custom tables in the GitLab database these tables and all data will be
gitlab_1      | 2021-01-01T11:44:43.005968729Z removed.
gitlab_1      | Installing configuration templates...
gitlab_1      | Configuring gitlab...
gitlab_1      | Configuring gitlab::database
gitlab_1      | Configuring gitlab::redis
gitlab_1      | Configuring gitlab::secrets...
gitlab_1      | Configuring gitlab::sidekiq...
gitlab_1      | Configuring gitlab::gitaly...
gitlab_1      | Configuring gitlab::monitoring...
gitlab_1      | Configuring gitlab::gitlab-workhorse...
gitlab_1      | Configuring gitlab::unicorn...
gitlab_1      | Configuring gitlab::timezone...
gitlab_1      | Configuring gitlab::rack_attack...
gitlab_1      | Configuring gitlab::ci...
gitlab_1      | Configuring gitlab::artifacts...
gitlab_1      | Configuring gitlab::lfs...
gitlab_1      | Configuring gitlab::uploads...
gitlab_1      | Configuring gitlab::mattermost...
gitlab_1      | Configuring gitlab::project_features...
gitlab_1      | Configuring gitlab::oauth...
gitlab_1      | Configuring gitlab::ldap...
gitlab_1      | Configuring gitlab::cron_jobs...
gitlab_1      | Configuring gitlab::backups...
gitlab_1      | Configuring gitlab::backups::aws...
gitlab_1      | Configuring gitlab::registry...
gitlab_1      | Configuring gitlab::pages...
gitlab_1      | Configuring gitlab::sentry...
gitlab_1      | Configuring gitlab-shell...
gitlab_1      | Configuring nginx...
gitlab_1      | Configuring nginx::gitlab...
gitlab_1      | gitlab_extensions:nginx: stopped
gitlab_1      | gitlab_extensions:sshd: stopped
gitlab_1      | gitlab_extensions:cron: stopped
gitlab_1      | gitlab:gitlab-workhorse: stopped
gitlab_1      | Running raketask gitlab:backup:restore...
postgresql_1  | 2021-01-01T11:44:58.769823233Z 2021-01-01 11:44:58.769 UTC [251] ERROR:  relation "feature_gates" does not exist at character 566
postgresql_1  | 2021-01-01T11:44:58.769848992Z 2021-01-01 11:44:58.769 UTC [251] STATEMENT:                SELECT a.attname, format_type(a.atttypid, a.atttypmod),
postgresql_1  | 2021-01-01T11:44:58.769853976Z                       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
postgresql_1  | 2021-01-01T11:44:58.769857610Z                       c.collname, col_description(a.attrelid, a.attnum) AS comment
postgresql_1  | 2021-01-01T11:44:58.769860704Z                  FROM pg_attribute a
postgresql_1  | 2021-01-01T11:44:58.769863456Z                  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
postgresql_1  | 2021-01-01T11:44:58.769866375Z                  LEFT JOIN pg_type t ON a.atttypid = t.oid
postgresql_1  | 2021-01-01T11:44:58.769869049Z                  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
postgresql_1  | 2021-01-01T11:44:58.769871859Z                 WHERE a.attrelid = '"feature_gates"'::regclass
postgresql_1  | 2021-01-01T11:44:58.769874732Z                   AND a.attnum > 0 AND NOT a.attisdropped
postgresql_1  | 2021-01-01T11:44:58.769877658Z                 ORDER BY a.attnum
postgresql_1  | 2021-01-01T11:44:58.769880277Z 
postgresql_1  | 2021-01-01T11:45:11.698772335Z 2021-01-01 11:45:11.698 UTC [253] ERROR:  relation "feature_gates" does not exist at character 566
postgresql_1  | 2021-01-01T11:45:11.698808374Z 2021-01-01 11:45:11.698 UTC [253] STATEMENT:                SELECT a.attname, format_type(a.atttypid, a.atttypmod),
postgresql_1  | 2021-01-01T11:45:11.698816817Z                       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
postgresql_1  | 2021-01-01T11:45:11.698822069Z                       c.collname, col_description(a.attrelid, a.attnum) AS comment
postgresql_1  | 2021-01-01T11:45:11.698826418Z                  FROM pg_attribute a
postgresql_1  | 2021-01-01T11:45:11.698830775Z                  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
postgresql_1  | 2021-01-01T11:45:11.698835222Z                  LEFT JOIN pg_type t ON a.atttypid = t.oid
postgresql_1  | 2021-01-01T11:45:11.698839384Z                  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
postgresql_1  | 2021-01-01T11:45:11.698844018Z                 WHERE a.attrelid = '"feature_gates"'::regclass
postgresql_1  | 2021-01-01T11:45:11.698848280Z                   AND a.attnum > 0 AND NOT a.attisdropped
postgresql_1  | 2021-01-01T11:45:11.698852335Z                 ORDER BY a.attnum
postgresql_1  | 2021-01-01T11:45:11.698856212Z 
gitlab_1      | Unpacking backup ... rake aborted!
gitlab_1      | NoMethodError: undefined method `chomp' for nil:NilClass
gitlab_1      | /home/git/gitlab/lib/gitlab/task_helpers.rb:62:in `prompt'
gitlab_1      | /home/git/gitlab/lib/gitlab/task_helpers.rb:27:in `ask_to_continue'
gitlab_1      | /home/git/gitlab/lib/tasks/gitlab/backup.rake:48:in `block (3 levels) in <top (required)>'
gitlab_1      | /home/git/gitlab/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
gitlab_1      | Tasks: TOP => gitlab:backup:restore
gitlab_1      | (See full trace by running task with --trace)
gitlab_1      | done
gitlab_1      | Before restoring the database, we will remove all existing
gitlab_1      | tables to avoid future upgrade problems. Be aware that if you have
gitlab_1      | custom tables in the GitLab database these tables and all data will be
gitlab_1      | removed.
gitlab_1      | Do you want to continue (yes/no)? 

At this point the container restarts.

danobot commented 3 years ago

Heres what I did to to make it work: Fresh install call docker-compose up -d. This creates the directory structure in gitlab data volume. Then copy the backup tar file into the backups folder.

Then run the following in docker compose directory:

docker-compose run --rm gitlab app:rake gitlab:backup:restore BACKUP=1609163751_2020_12_28_12.7.7

I didnt realise docker-compose run would set up the container and all its volumes and dependencies according to docker-compose file. The provided steps work after all. :)

kkimurak commented 3 years ago

Those command ( app:init, app:start, app:sanitize, app:rake ) are defined in entrypoint.sh, so running it inside container is not the expected usage.
From your comments, I guess you're using docker-compose, so the command to execute will be:

docker-compose run --rm gitlab app:rake gitlab:backup:restore BACKUP=1609163751_2020_12_28_12.7.7

See Restoring instruction in README for more detail.

kkimurak commented 3 years ago

Oops, sorry for duplicate answer.

danobot commented 3 years ago

yeah I misinterpreted the readme. confusing docker-compose run with docker run. Got there in the end.