我正在使用以下指南将Gitlab服务器迁移到Omnibus版本:http://theterminallife.com/migrating-gitlab-to-gitlab-omnibus/
在备份恢复时,一切都达到了rake脚本的作用,我在反引号上遇到了几个语法错误。
@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中有一个相关的错误报告,但它已被弃用,我似乎无法找到这个错误发生的位置。我非常感谢有助于追踪这一点。谢谢。
答案 0 :(得分:0)
这通常发生在从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