gitlab 备份恢复因错误 "relation not found" 而中止
gitlab backup restore aborting with error "relation not found"
正在使用 gitlab-omnibus 设置新服务器 (Ubuntu 14.04),我想导入我的旧 gitlab 数据。我按照 readme 中的说明将旧安装升级到 7.10.1 以匹配新安装。
将备份复制到正确位置后,停止 unicorn 和 sidekiq,将备份文件的所有者设置为新服务器上的 git
和 运行 sudo gitlab-rake gitlab:backup:restore BACKUP=XXXXXX
,我得到
** Invoke gitlab:backup:restore (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute gitlab:backup:restore
Unpacking backup ... done
** Invoke gitlab:backup:db:restore (first_time)
** Invoke environment
** Execute gitlab:backup:db:restore
Restoring database ...
Restoring PostgreSQL database gitlabhq_production ... ** Invoke gitlab:db:drop_all_tables (first_time)
** Invoke environment
** Execute gitlab:db:drop_all_tables
** Invoke gitlab:db:drop_all_postgres_sequences (first_time)
** Invoke environment
** Execute gitlab:db:drop_all_postgres_sequences
psql:/var/opt/gitlab/backups/db/database.sql:22: ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `application_settings`;
^
...
psql:/var/opt/gitlab/backups/db/database.sql:172: invalid command \'
psql:/var/opt/gitlab/backups/db/database.sql:1135: ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `events` VALUES (17,NULL,NULL,NULL,NULL,5,'2014-...
^
[DONE]
done
** Invoke gitlab:backup:repo:restore (first_time)
** Invoke environment
** Execute gitlab:backup:repo:restore
Restoring repositories ...
rake aborted!
ActiveRecord::StatementInvalid: PG::Error: ERROR: relation "projects" does not exist
LINE 1: SELECT "projects".* FROM "projects" ORDER BY "projects"."...
^
: SELECT "projects".* FROM "projects" ORDER BY "projects"."id" ASC LIMIT 1000
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `exec'
...
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/rake:23:in `load'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/rake:23:in `<main>'
PG::Error: ERROR: relation "projects" does not exist
LINE 1: SELECT "projects".* FROM "projects" ORDER BY "projects"."...
^
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `exec'
...
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/rake:23:in `<main>'
Tasks: TOP => gitlab:backup:repo:restore
我仍然不确定这是错误还是服务器配置错误。也许你可以帮助我,了解发生了什么。
database.sql
好像没问题。
gitlab:check
只会遇到同样的错误。
一段时间后答案就很明显了。我只是试图将 MySQL-Backup 恢复到 PostgreSQL 数据库中,这不是个好主意。将 MySQL- 翻译成 PostgreSQL-Style SQL 应该可以解决问题。
正在使用 gitlab-omnibus 设置新服务器 (Ubuntu 14.04),我想导入我的旧 gitlab 数据。我按照 readme 中的说明将旧安装升级到 7.10.1 以匹配新安装。
将备份复制到正确位置后,停止 unicorn 和 sidekiq,将备份文件的所有者设置为新服务器上的 git
和 运行 sudo gitlab-rake gitlab:backup:restore BACKUP=XXXXXX
,我得到
** Invoke gitlab:backup:restore (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute gitlab:backup:restore
Unpacking backup ... done
** Invoke gitlab:backup:db:restore (first_time)
** Invoke environment
** Execute gitlab:backup:db:restore
Restoring database ...
Restoring PostgreSQL database gitlabhq_production ... ** Invoke gitlab:db:drop_all_tables (first_time)
** Invoke environment
** Execute gitlab:db:drop_all_tables
** Invoke gitlab:db:drop_all_postgres_sequences (first_time)
** Invoke environment
** Execute gitlab:db:drop_all_postgres_sequences
psql:/var/opt/gitlab/backups/db/database.sql:22: ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `application_settings`;
^
...
psql:/var/opt/gitlab/backups/db/database.sql:172: invalid command \'
psql:/var/opt/gitlab/backups/db/database.sql:1135: ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `events` VALUES (17,NULL,NULL,NULL,NULL,5,'2014-...
^
[DONE]
done
** Invoke gitlab:backup:repo:restore (first_time)
** Invoke environment
** Execute gitlab:backup:repo:restore
Restoring repositories ...
rake aborted!
ActiveRecord::StatementInvalid: PG::Error: ERROR: relation "projects" does not exist
LINE 1: SELECT "projects".* FROM "projects" ORDER BY "projects"."...
^
: SELECT "projects".* FROM "projects" ORDER BY "projects"."id" ASC LIMIT 1000
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `exec'
...
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/rake:23:in `load'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/rake:23:in `<main>'
PG::Error: ERROR: relation "projects" does not exist
LINE 1: SELECT "projects".* FROM "projects" ORDER BY "projects"."...
^
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `exec'
...
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/rake:23:in `<main>'
Tasks: TOP => gitlab:backup:repo:restore
我仍然不确定这是错误还是服务器配置错误。也许你可以帮助我,了解发生了什么。
database.sql
好像没问题。
gitlab:check
只会遇到同样的错误。
一段时间后答案就很明显了。我只是试图将 MySQL-Backup 恢复到 PostgreSQL 数据库中,这不是个好主意。将 MySQL- 翻译成 PostgreSQL-Style SQL 应该可以解决问题。