转换为PostgreSQL后备份还原时出错

转换为PostgreSQL后备份还原时出错,sql,postgresql,rake,gitlab,gitlab-omnibus,Sql,Postgresql,Rake,Gitlab,Gitlab Omnibus,我正在使用以下指南将Gitlab服务器迁移到Omnibus版本: 在备份还原的rake脚本中,我在backticks中发现了几个语法错误 @GitLabVM:~$ sudo gitlab-rake gitlab:backup:restore BACKUP=1452260428 Unpacking backup ... done Restoring database ... Restoring PostgreSQL database gitlabhq_production ... ERROR:

我正在使用以下指南将Gitlab服务器迁移到Omnibus版本:

在备份还原的rake脚本中,我在backticks中发现了几个语法错误

@GitLabVM:~$ sudo gitlab-rake gitlab:backup:restore BACKUP=1452260428
Unpacking backup ... done
Restoring database ...
Restoring PostgreSQL database gitlabhq_production ... ERROR:  syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `abuse_reports`;
                             ^
ERROR:  syntax error at or near "`"
LINE 1: CREATE TABLE `abuse_reports` (
                     ^
ERROR:  syntax error at or near "`"
LINE 1: LOCK TABLES `abuse_reports` WRITE;
                    ^
ERROR:  syntax error at or near "UNLOCK"
LINE 1: UNLOCK TABLES;
        ^
ERROR:  syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `application_settings`;
                             ^
ERROR:  syntax error at or near "`"
LINE 1: CREATE TABLE `application_settings` (
                     ^
ERROR:  syntax error at or near "`"
LINE 1: LOCK TABLES `application_settings` WRITE;
                    ^
ERROR:  syntax error at or near "`"
LINE 1: INSERT INTO `application_settings` VALUES (1,10,1,1,1,NULL,'...
                    ^
ERROR:  syntax error at or near "UNLOCK"
LINE 1: UNLOCK TABLES;
        ^
ERROR:  syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `audit_events`;
我已经检查了sql文件,它没有我收到错误的背景标记

-- Converted by db_converter
START TRANSACTION;
SET standard_conforming_strings=off;
SET escape_string_warning=off;
SET CONSTRAINTS ALL DEFERRED;

DROP TABLE IF EXISTS "abuse_reports";
CREATE TABLE "abuse_reports" (
    "id" integer NOT NULL,
    "reporter_id" integer DEFAULT NULL,
    "user_id" integer DEFAULT NULL,
    "message" text ,
    "created_at" timestamp with time zone DEFAULT NULL,
    "updated_at" timestamp with time zone DEFAULT NULL,
    PRIMARY KEY ("id")
);

DROP TABLE IF EXISTS "application_settings";
CREATE TABLE "application_settings" (
    "id" integer NOT NULL,
    "default_projects_limit" integer DEFAULT NULL,
    "signup_enabled" int4 DEFAULT NULL,
    "signin_enabled" int4 DEFAULT NULL,
    "gravatar_enabled" int4 DEFAULT NULL,
.....
.....
Gitlab中有一个相关的bug报告,但它已被弃用,我似乎无法找到这个bug发生的地方。如果您能帮我找到这件事,我将不胜感激。多谢各位


这通常发生在从MySQL数据库创建转储时,以及在恢复过程中Postgress db收到这些语法错误时

您可以创建一个与PostgreSQL兼容的单独数据库转储,只需执行以下步骤即可

sudo -u git -H mysqldump --compatible=postgresql--default-character-set=utf8 -r gitlabhq_production.mysql -u root gitlabhq_production -p

# Clone the database converter
sudo -u git -H git clone https://github.com/gitlabhq/mysql-postgresql-converter.git -b gitlab

# Convert gitlabhq_production.mysql
sudo -u git -H mkdir db
sudo -u git -H python mysql-postgresql-converter/db_converter.py gitlabhq_production.mysql db/database.sql
sudo -u git -H ed -s db/database.sql < mysql-postgresql-converter/move_drop_indexes.ed

# Compress database backup
# Warning: If you have Gitlab 7.12.0 or older skip this step and import the database.sql directly into the backup with:
# sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql
# The compressed databasedump is not supported at 7.12.0 and older.
sudo -u git -H gzip db/database.sql

# Replace the MySQL dump in TIMESTAMP_gitlab_backup.tar.

# Warning: if you forget to replace TIMESTAMP below, tar will create a new file
# 'TIMESTAMP_gitlab_backup.tar' without giving an error.

sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql.gz

# Done! TIMESTAMP_gitlab_backup.tar can now be restored into a Postgres GitLab
# installation.
# See https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md for more information about backups.
https://docs.gitlab.com/ee/update/mysql_to_postgresql.html#converting-a-gitlab-backup-file-from-mysql-to-postgres
sudo-u git-H mysqldump--compatible=postgresql--default character set=utf8-r gitlabhq_production.mysql-u root gitlabhq_production-p
#克隆数据库转换器
sudo-u git-H git克隆https://github.com/gitlabhq/mysql-postgresql-converter.git -吉特拉布
#转换gitlabhq_production.mysql
sudo-u git-H mkdir db
sudo-u git-H python mysql postgresql converter/db_converter.py gitlabhq_production.mysql db/database.sql
sudo-u git-H ed-s db/database.sql

请参阅:

这通常发生在从MySQL数据库创建转储时,以及在恢复过程中Postgress db收到这些语法错误时

您可以创建一个与PostgreSQL兼容的单独数据库转储,只需执行以下步骤即可

sudo -u git -H mysqldump --compatible=postgresql--default-character-set=utf8 -r gitlabhq_production.mysql -u root gitlabhq_production -p

# Clone the database converter
sudo -u git -H git clone https://github.com/gitlabhq/mysql-postgresql-converter.git -b gitlab

# Convert gitlabhq_production.mysql
sudo -u git -H mkdir db
sudo -u git -H python mysql-postgresql-converter/db_converter.py gitlabhq_production.mysql db/database.sql
sudo -u git -H ed -s db/database.sql < mysql-postgresql-converter/move_drop_indexes.ed

# Compress database backup
# Warning: If you have Gitlab 7.12.0 or older skip this step and import the database.sql directly into the backup with:
# sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql
# The compressed databasedump is not supported at 7.12.0 and older.
sudo -u git -H gzip db/database.sql

# Replace the MySQL dump in TIMESTAMP_gitlab_backup.tar.

# Warning: if you forget to replace TIMESTAMP below, tar will create a new file
# 'TIMESTAMP_gitlab_backup.tar' without giving an error.

sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql.gz

# Done! TIMESTAMP_gitlab_backup.tar can now be restored into a Postgres GitLab
# installation.
# See https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md for more information about backups.
https://docs.gitlab.com/ee/update/mysql_to_postgresql.html#converting-a-gitlab-backup-file-from-mysql-to-postgres
sudo-u git-H mysqldump--compatible=postgresql--default character set=utf8-r gitlabhq_production.mysql-u root gitlabhq_production-p
#克隆数据库转换器
sudo-u git-H git克隆https://github.com/gitlabhq/mysql-postgresql-converter.git -吉特拉布
#转换gitlabhq_production.mysql
sudo-u git-H mkdir db
sudo-u git-H python mysql postgresql converter/db_converter.py gitlabhq_production.mysql db/database.sql
sudo-u git-H ed-s db/database.sql

请参阅:

您是否找到了此问题的解决方案?您是否找到了此问题的解决方案?