vBulletin 4 포럼을 Discourse로 마이그레이션하기

이 가이드는 script/import_scripts/vbulletin.rb 임포터 스크립트를 사용하여 vBulletin 4 포럼을 Discourse로 마이그레이팅하는 방법을 다룹니다.

:warning: 스크립트를 수정해야 할 수 있음을 감안하세요. 모든 vBulletin 설치에는 자체 플러그인, 사용자 정의 필드 및 BBCode 특이점이 있습니다. 대부분의 실제 가져오기에는 스크립트에 약간의 변경이 필요합니다. 프로덕션 환경에 손대기 전에 개발 머신에서 전체 테스트 가져오기를 수행하세요.

어떤 임포터를 사용해야 하나요?

포럼 스크립트
vBulletin 4 script/import_scripts/vbulletin.rb (이 가이드)
vBulletin 3 script/import_scripts/vbulletin3.rb (단계는 동일하지만 스크립트 이름이 다름)
vBulletin 5 script/import_scripts/vbulletin5.rb
매우 큰 포럼 (수백만 개의 게시물) script/bulk_import/vbulletin.rb (훨씬 빠르지만 기능이 적고 사용자 지정이 어려움)

가져오기 대상

  • 그룹
  • 사용자 (금지된 사용자는 일시 정지된 사용자가 됨)
  • 포럼: 각 상위 및 하위 포럼은 카테고리 및 하위 카테고리가 됩니다.
  • 주제
  • 고정된 스레드 → 고정된 주제로 변환
  • 닫힌 스레드 → 닫힌 주제로 변환
  • 소프트 삭제 또는 moderated된 스레드 → 비공개 목록 주제로 변환
  • 게시물
  • 개인 메시지
  • 첨부 파일
  • 아바타 (데이터베이스에 저장된 경우에만, 아래 참조)
  • 주제용 고정 링크(Permalinks)

주의 사항

  • 중단된 가져오기를 재개하고 새로운 데이터베이스 스냅샷을 대상으로 다시 실행하여 새 콘텐츠를 가져올 수 있습니다. 이미 가져온 콘텐츠는 후속 편집으로 업데이트되지 않습니다.

  • Discourse는 두 단계의 카테고리를 지원합니다. 더 깊이 중첩된 포럼은 평탄화(flatten)됩니다.

  • BBCode 목록 ([ul], [ol], [li])은 완전히 변환되지 않으며 수동으로 정리해야 할 수 있습니다.

내보내기 전에

vBulletin이 파일 시스템에 아바타를 저장하는 경우 임포터가 이를 찾을 수 없습니다. vBulletin 사이트에서 /admincp/avatar.php?do=storage를 방문하여 내보내기 전에 아바타를 데이터베이스로 이동하세요.

그런 다음 vBulletin 서버에서 데이터베이스를 내보냅니다:

mysqldump -u USERNAME -p DATABASE_NAME | gzip > vb4_dump.sql.gz

dump와 첨부 파일 폴더를 가져오기할 머신으로 복사합니다 (예: scp 또는 rsync 사용). vBulletin 관리자 설정에 첨부 파일 저장 위치가 표시됩니다.

옵션 A: 개발 머신에서 가져오기 (권장)

로컬에서 가져오기를 수행하면 빠르게 반복할 수 있고 실패한 시도는 버리면 됩니다. 결과가 올바로 보이면 사이트를 백업하고 프로덕션 환경에 복원합니다.

  1. Ubuntu/Debian 또는 macOS 가이드를 따라 Discourse 개발 환경 설정을 완료하세요.

  2. MariaDB를 설치합니다. MySQL의 drop-in replacement(대체재)이며, 현재 배포판에는 MySQL 5.7 패키지가 더 이상 제공되지 않습니다.

    # Ubuntu/Debian
    sudo apt-get update
    sudo apt-get install mariadb-server libmariadb-dev
    sudo service mariadb start
    
     # macOS
     brew install mariadb
     brew services start mariadb
    
  3. 임포터 Gem을 설치합니다. IMPORT=1이 설정되면 mysql2가 포함됩니다. php-serialize를 추가해야 합니다:

    cd ~/discourse
    echo "gem 'php-serialize', require: false" >> Gemfile
    IMPORT=1 bundle install
    
  4. vBulletin 데이터베이스 로드:

    sudo mysql -e "CREATE DATABASE vb4"
    gunzip < vb4_dump.sql.gz | sudo mysql vb4
    
  5. 빈 Discourse 데이터베이스로 시작:

    bin/rails db:drop db:create db:migrate
    
  6. 임포터 실행. 이미 가져온 콘텐츠를 건너뛰므로 언제든지 중지하고 다시 시작할 수 있습니다.

    export DB_HOST="localhost"  
    export DB_NAME="vb4"
    export DB_USER="root"
    export DB_PW=""                                # 설정한 경우 MariaDB root 비밀번호
    export TABLE_PREFIX="vb_"                      # 테이블 접두사, 없으면 ""
    export ATTACHMENT_DIR="/path/to/attachments"   # 복사한 첨부 파일 폴더
    export TIMEZONE="America/Los_Angeles"          # vBulletin이 사용한 시간대
    
    IMPORT=1 bundle exec ruby script/import_scripts/vbulletin.rb
    
  7. Discourse를 시작하고 백그라운드 작업이 완료되도록 합니다. bin/dev를 실행하고 두 번째 터미널에서 bundle exec sidekiq를 실행합니다. 큰 포럼의 경우 게시물 재베이크 및 이미지 처리에 시간이 오래 걸릴 수 있습니다. http://localhost:4200/sidekiq에서 진행 상황을 추적할 수 있습니다.

  8. 프로덕션으로 이동. 다른 VPS로 Discourse 사이트 이동을 따라 백업을 만들고 프로덕션 사이트에 복원합니다.

옵션 B: 프로덕션 컨테이너에서 직접 가져오기

  1. **표준 설치 가이드**로 Discourse를 설치합니다.

  2. 사이트 설정 조정 (아래 권장 사이트 설정 참조).

  3. dump와 첨부 파일을 호스트의 /var/discourse/shared/standalone/에 복사합니다. 컨테이너 내부에서는 /shared/ 아래에 표시되며, 해당 파일은 컨테이너 재구축 후에도 유지됩니다.

  4. 컨테이너에 들어가서 MariaDB를 설치합니다:

    cd /var/discourse
    ./launcher enter app
    apt-get update
    apt-get install -y mariadb-server libmariadb-dev
    service mariadb start
    
  5. 임포터 Gem을 설치합니다:

    cd /var/www/discourse
    echo "gem 'php-serialize', require: false" >> Gemfile
    su discourse -c 'bundle config set --local deployment false && bundle config set --local frozen false'
    su discourse -c 'IMPORT=1 bundle install'
    
  6. vBulletin 데이터베이스 로드:

    mysql -e "CREATE DATABASE vb4"
    gunzip < /shared/vb4_dump.sql.gz | mysql vb4
    
  7. 임포터 실행. SSH 연결이 끊어져도 중단되지 않도록 tmux 또는 screen 내에서 실행하세요.

    cd /var/www/discourse
    su discourse -c 'DB_NAME=vb4 DB_USER=root DB_PW="" TABLE_PREFIX=vb_ \
    ATTACHMENT_DIR=/shared/attachments TIMEZONE=America/Los_Angeles \
    IMPORT=1 bundle exec ruby script/import_scripts/vbulletin.rb'
    
  8. 정리. /shared에 복사한 파일을 삭제한 다음 컨테이너를 재구축합니다. 재구축 시 MariaDB와 추가 Gem이 제거되고 원본 Gemfile이 복원됩니다.

    exit
    cd /var/discourse
    ./launcher rebuild app
    

권장 사이트 설정

가져오기 전에 이를 설정하세요. 테스트 가져오기를 반복해서 실행할 때 도움이 되도록 script/import_scripts/base.rb의 get_site_settings_for_import에도 설정할 수 있습니다.

  • login_required: 가져오기 완료 및 확인까지 이를 활성화하세요.

  • slug_generation_method: 포럼 언어가 영어가 아닌 경우 주제 URL에 비ASCII 제목이 유지되도록 encoded로 설정하세요.

  • download_remote_images_to_local: 오래된 게시물에 핫링크된 이미지를 Discourse가 다운로드하지 않도록 하려면 이를 비활성화하세요.

  • disable_system_edit_notifications: 시스템이 이미지를 처리하는 동안 편집된 모든 게시물에 대해 사용자가 알림을 받지 않도록 이를 활성화하세요.

알려진 문제

  • parse_timestamp에서의 Integer values are not supported (ArgumentError). 이는 새로운 버전의 tzinfo와 함께 실행되는 구버전 스크립트 사본에 영향을 미칩니다. 최신 Discourse로 업데이트하거나 parse_timestamp를 다음과 같이 변경하세요:

    def parse_timestamp(timestamp)
    return nil if timestamp.blank?
       Time.zone.at(@tz.utc_to_local(Time.at(timestamp.to_i)))
    end
    
  • 공백이 있는 사용자 이름이 포함된 인용문 또는 중첩된 인용문은 변환되지 않습니다. 개선된 정규식 표현은 이 답변을 참조하세요.

  • Can't connect to local server through socket. MariaDB가 실행 중이 아닙니다. service mariadb start로 시작하세요.

21개의 좋아요

The script will now import avatars, but they must be embedded into the database. To do so, I’m told that you visit /admincp/avatar.php?do=storage and do something there. It seemed to work for the last client I did an import for.

Hey, @erlend_sh, make this a wiki and I’ll add to it in a few days when I submit a PR for this importer.

6개의 좋아요

I was following your guide to import my vBulletin forum to Discourse. I am using a docker container for Discourse. I ran the following command:

I got a long list of errors:

sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
[...]
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified

Bundler::SudoNotPermittedError: Bundler requires sudo access to install at the moment. Try installing again, granting Bundler sudo access when
prompted, or installing into a different path.
An error occurred while installing rake (11.2.2), and Bundler cannot continue.
Make sure that `gem install rake -v '11.2.2'` succeeds before bundling.

I am new to ruby on rails and dockers. I do understand the concept of gems and Bundler.
What do these errors mean and how can I resolve them?

1개의 좋아요

Ok so basically I had to install all the necessary gems.
The script worked quite well.

However, I am not able to login with one of the users I created on my vBulletin forum just before importing the database over to discourse.

1개의 좋아요

You’ll need to set passwords. The script doesn’t import them (last I looked).

And even if it did, you’d need to install a plugin to make them work.

1개의 좋아요

I am planning to write a script that will import the passwords for my case.
I know the mysql tables I need to consider for vBulletin. What is the table in PostgreSQL for Discourse that stores passwords and is used during login?

Prakarsh would you be able to share the forum url that you are trying to switch from? The vBulletin one. Will the Discourse one have the same URL?

Yes. Here it is: Brainstorm

Our plan is to keep the URL same for now. I cannot say when it will be live. Probably by end of next week if everything goes right :stuck_out_tongue:

1개의 좋아요

Before you do that, you should read this topic.

You don’t want to directly touch the Discourse tables. You want a script like this. When I last used it and tried to import the passwords, it ran really slowly. I’m not sure why, but after reading this I decided that it’s probably not a bad idea to make people change their passwords.

3개의 좋아요

@pfaffman - You mentioned you used import_pass field in your import script.
Where exactly do you put the import_pass field? And how do you use it?
If you could share it would be great help.

I have tried using this script but it failed 90% into the import of the users:

su discourse -c 'RAILS_ENV=production ruby script/import_scripts/vbulletin.rb'
root:XXXX@localhost wants vb4
loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...

importing groups...
        6 / 19 ( 31.6%)  Failed to create group id 7 Moderators: ["Name has already been taken"]
       19 / 19 (100.0%)  
importing users
     2746 / 15319 ( 17.9%)  W, [2017-10-12T10:07:05.104837 #3578]  WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
W, [2017-10-12T10:07:05.106562 #3578]  WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
W, [2017-10-12T10:07:05.107305 #3578]  WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
    13901 / 15319 ( 90.7%)  script/import_scripts/vbulletin.rb:137:in `strip': invalid byte sequence in UTF-8 (ArgumentError)
        from script/import_scripts/vbulletin.rb:137:in `block (2 levels) in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:226:in `block in create_users'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `each'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `create_users'
        from script/import_scripts/vbulletin.rb:133:in `block in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:784:in `block in batches'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `loop'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `batches'
        from script/import_scripts/vbulletin.rb:117:in `import_users'
        from script/import_scripts/vbulletin.rb:78:in `execute'
        from /var/www/discourse/script/import_scripts/base.rb:45:in `perform'
        from script/import_scripts/vbulletin.rb:902:in `<main>'

Anyone have any suggestions regarding how to debug and fix this?

You have an encoding problem in your database.

The database claims is using one encoding, but some of the data is encoded some other way. A job I just did had a similar problem. UTF-8 likely does not exist when you started your forum.

This is probably a problem for stack exchange or a database person. It’s not a problem with the importer.

It’s the kind of problem that will take 10 minutes following a recipe that you don’t understand, ten hours looking for that recipe, or 100 hours fixing it by hand.

3개의 좋아요

Cheers @pfaffman I was approaching the same conclusion… I started writing up the following before your comment…

It looks like it might be caused by non-ascii characters in usernames, so dumping the usernames into a text file and searching for UTF-8:

echo "select username from user" | mysql -p vb4 | grep --color='auto' -P -n "[^[:ascii:]]"

These were the entities this threw up:

’ ´ – é ã Ñ í ó 

So I used this page to generate encoded versions and updated the usernames in the database, for example:

UPDATE user SET username="&rsquo; &acute; &ndash; &eacute; &atilde; &Ntilde; &iacute; &oacute;" WHERE username="’ ´ – é ã Ñ í ó"

But the script still fails:

script/import_scripts/vbulletin.rb:137:in `strip': invalid byte sequence in UTF-8 (ArgumentError)
        from script/import_scripts/vbulletin.rb:137:in `block (2 levels) in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:226:in `block in create_users'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `each'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `create_users'
        from script/import_scripts/vbulletin.rb:133:in `block in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:784:in `block in batches'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `loop'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `batches'
        from script/import_scripts/vbulletin.rb:117:in `import_users'
        from script/import_scripts/vbulletin.rb:78:in `execute'
        from /var/www/discourse/script/import_scripts/base.rb:45:in `perform'
        from script/import_scripts/vbulletin.rb:902:in `<main>'

So I then dumped the whole users table into a text file:

echo "select * from user" | mysql -p vb4 > /tmp/allusers.txt

And then tried all the suggesting in this stackexchange thread for finding non-ascii characters and none were found, so now to search the whole database for the problem…

When I find a solution I’ll post it here in case it helps others…

2개의 좋아요

The problem almost certainly exists in other tables.

You need to figure out what it’s encoded in and fix it.

Or, it could be that for some years it’s in one encoding and other years it’s another.

Best of luck. I was relieved they my client had engineers they solved the problem so I didn’t have to. I may have some notes that I’ll try to find when I get out of bed.

1개의 좋아요

The database on the old server was UTF-8 but clearly it has some non-UTF-8 in it, the site has been in use for a long time and has 13k users… so taking care with dumping the old database:

mysqldump -uroot -p database -r dump.sql

And trying various methods to check the encoding (thanks to Stackexchange):

file dump.sql 
  dump.sql: ASCII text, with very long lines

apt install uchardet 
uchardet dump.sql
  UTF-8

iconv -f utf-8 -t utf-8 dump.sql > dump.utf-8.sql
  iconv: illegal input sequence at position 29618109

apt install moreutils
isutf8 dump.sql 
  dump.sql: line 2995, char 42, byte 29618109: Expecting bytes in the following ranges: 00..7F C2..F4.

And this is a image line:

INSERT INTO `customavatar` VALUES (6355,'ÿØÿà\0^PJFIF\0^A^A\0\0^A\0^A\0\0ÿþ\0;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75

And before I delete the line using vim I need to increase the size of the partitions as it is a 1.4G file and I’m running out of space when editing it…

1개의 좋아요

The problem was a user with &#55357;&#56444; in the username field, once the HTML entities were removed the import script ran, but there were a lot of errors like this:

ERR Error running script (call to f_b06356ba4628144e123b652c99605b873107c9be): @user_script:14: @user_script: 14: -MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. 

Is this something that I should be concerned about and something that I should fix and then redo the import?

Are you out of disk space?

1개의 좋아요

Yes! I’m now spinning up a new virtual server with a huge amount of disk space, CPUs and RAM and I’m going to start from scratch…

By the way, I’m following the instructions above for the Docker version and found that I needed to add an additional step in the container

echo "discourse ALL = NOPASSWD: ALL" >> /etc/sudoers

Before running:

su discourse -c 'bundle install --no-deployment --without test --without development'

In the non-docker instructions above there is this step to delete data from the database before doing the import:

  • Clear existing data from your local Discourse instance
cd ~/discourse
bundle exec rake db:drop db:create db:migrate

Was this omitted from the Docker instructions on purpose?

1개의 좋아요

There are two, different, vbulletin import scripts, in the docker container:

cd /var/www/discourse
find ./ -name vbulletin.rb
./script/bulk_import/vbulletin.rb
./script/import_scripts/vbulletin.rb

The second one is twice the size of the first one and it is the one I have been using.