Espere precisar ajustar o script. Cada instalação do vBulletin possui seus próprios plugins, campos personalizados e peculiaridades de BBCode. A maioria das importações reais necessita de pequenas alterações no script. Faça uma importação de teste completa em uma máquina de desenvolvimento antes de mexer na produção.
Qual importador devo usar?
Fórum
Script
vBulletin 4
script/import_scripts/vbulletin.rb (este guia)
vBulletin 3
script/import_scripts/vbulletin3.rb (mesmos passos, nome de script diferente)
vBulletin 5
script/import_scripts/vbulletin5.rb
Fóruns muito grandes (milhões de posts)
script/bulk_import/vbulletin.rb (muito mais rápido, mas possui menos recursos e é mais difícil de personalizar)
Fóruns: cada fórum pai e filho torna-se uma categoria e subcategoria
Tópicos
Tópico fixado → tópico fixado (pinned)
Tópico fechado → tópico fechado
Tópico excluído suavemente ou moderado → tópico não listado (unlisted)
Posts
Mensagens privadas
Anexos
Avatares (somente se estiverem armazenados no banco de dados, veja abaixo)
Links permanentes (permalinks) para tópicos
Ressalvas
Você pode retomar uma importação interrompida e executá-la novamente contra um snapshot mais recente do banco de dados para obter o novo conteúdo. O conteúdo já importado não será atualizado com edições posteriores.
O Discourse suporta dois níveis de categorias. Fóruns aninhados mais profundamente são achatados (flatened).
Listas BBCode ([ul], [ol], [li]) não são totalmente convertidas e podem necessitar de limpeza manual.
Antes de exportar
Se o vBulletin armazenar avatares no sistema de arquivos, o importador não os encontrará. Acesse /admincp/avatar.php?do=storage no seu site vBulletin e mova os avatares para o banco de dados antes de exportá-lo.
Em seguida, exporte o banco de dados no servidor vBulletin:
Copie o dump e a pasta de anexos para a máquina na qual você realizará a importação (por exemplo, com scp ou rsync). Suas configurações de administrador do vBulletin mostram onde os anexos são armazenados.
Opção A: Importar em uma máquina de desenvolvimento (recomendado)
Importar localmente permite que você itere rapidamente e descarte tentativas malsucedidas. Quando o resultado parecer correto, faça um backup do site e restaure-o em produção.
Configure um ambiente de desenvolvimento Discourse seguindo o guia para Ubuntu/Debian ou macOS.
Instale o MariaDB. É um substituto direto para o MySQL, e os pacotes do MySQL 5.7 não estão mais disponíveis em distribuições atuais.
sudo mysql -e "CREATE DATABASE vb4"
gunzip < vb4_dump.sql.gz | sudo mysql vb4
Comece com um banco de dados Discourse vazio:
bin/rails db:drop db:create db:migrate
Execute o importador. Você pode pará-lo e reiniciá-lo a qualquer momento, pois ele pula o conteúdo que já foi importado.
export DB_HOST="localhost"
export DB_NAME="vb4"
export DB_USER="root"
export DB_PW="" # Senha root do MariaDB, se você definiu uma
export TABLE_PREFIX="vb_" # Seu prefixo de tabela, ou "" se não houver nenhum
export ATTACHMENT_DIR="/path/to/attachments" # A pasta de anexos que você copiou
export TIMEZONE="America/Los_Angeles" # O fuso horário que o vBulletin usava
IMPORT=1 bundle exec ruby script/import_scripts/vbulletin.rb
Inicie o Discourse e deixe que as tarefas em segundo plano concluam. Execute bin/dev e, em um segundo terminal, execute bundle exec sidekiq. A refornada de posts e o processamento de imagens podem demorar muito em um fórum grande. Você pode acompanhar o progresso em http://localhost:4200/sidekiq.
Copie o dump e os anexos para /var/discourse/shared/standalone/ no host. Dentro do container, eles aparecem sob /shared/, e os arquivos lá sobrevivem a uma reconstrução do container.
Entre no container e instale o MariaDB:
cd /var/discourse
./launcher enter app
apt-get update
apt-get install -y mariadb-server libmariadb-dev
service mariadb start
Instale as gems do importador:
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'
Carregue o banco de dados do vBulletin:
mysql -e "CREATE DATABASE vb4"
gunzip < /shared/vb4_dump.sql.gz | mysql vb4
Execute o importador. Execute-o dentro de tmux ou screen para que uma desconexão SSH não o mate.
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'
Limpeza. Exclua os arquivos que você copiou para /shared, então reconstrua o container. A reconstrução remove o MariaDB e as gems extras e restaura o Gemfile original.
exit
cd /var/discourse
./launcher rebuild app
Configurações recomendadas do site
Defina estas configurações antes de importar. Você também pode defini-las em get_site_settings_for_import em script/import_scripts/base.rb, o que ajuda quando você executa importações de teste repetidamente.
login_required: habilite isto até que a importação seja concluída e verificada.
slug_generation_method: defina para encoded se o seu fórum não for em inglês, para que os URLs dos tópicos mantenham seus títulos não-ASCII.
download_remote_images_to_local: desabilite isto se você não quiser que o Discourse baixe imagens vinculadas diretamente (hotlinked) em posts antigos.
disable_system_edit_notifications: habilite isto para que os usuários não sejam notificados sobre cada post que o sistema edita enquanto processa as imagens.
Problemas conhecidos
Integer values are not supported (ArgumentError) em parse_timestamp. Isto afeta cópias antigas do script rodando com versões mais novas da tzinfo. Atualize para a versão mais recente do Discourse, ou altere parse_timestamp para:
def parse_timestamp(timestamp)
return nil if timestamp.blank?
Time.zone.at(@tz.utc_to_local(Time.at(timestamp.to_i)))
end
Citações com nomes de usuário que possuem espaços, ou citações aninhadas, não são convertidas. Veja esta resposta para regexes aprimoradas.
Can't connect to local server through socket. O MariaDB não está sendo executado. Inicie-o com service mariadb start.
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.
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?
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?
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.
@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?
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.
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="’ ´ – é ã Ñ í ó" 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…
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.
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 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…
The problem was a user with �� 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?