توقع تعديل السكربت. كل تثبيت لـ 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 (أسرع بكثير، لكن يحتوي على ميزات أقل ويكون من الصعب تخصيصه)
المنتديات: يصبح كل منتدى أب وابنه فئة وفئة فرعية على التوالي
الموضوعات
الموضوع المثبت (Sticky thread) ← موضوع مثبت (Pinned topic)
الموضوع المغلق (Closed thread) ← موضوع مغلق (Closed topic)
الموضوع المحذوف ناعماً أو المعدّل ← موضوع غير مُدرج (Unlisted topic)
المشاركات
الرسائل الخاصة
المرفقات
الصور الرمزية (Avatars) (فقط إذا كانت مخزنة في قاعدة البيانات، انظر أدناه)
الروابط الدائمة (Permalinks) للموضوعات
ملاحظات وتحذيرات
يمكنك استئناف استيراد متوقف وإعادة تشغيله مقابل لقطة أحدث من قاعدة البيانات لالتقاط المحتوى الجديد. لن يتم تحديث المحتوى الذي تم استيراده بالفعل مع التعديلات اللاحقة.
يدعم Discourse مستويين من الفئات. يتم تسطيح المنتديات المتداخلة بأعمق من ذلك.
قوائم BBCode ([ul]، [ol]، [li]) لا يتم تحويلها بالكامل وقد تحتاج إلى تنظيف يدوي.
قبل التصدير
إذا كان vBulletin يخزن الصور الرمزية في نظام الملفات، فلن يجدها المستورد. زر /admincp/avatar.php?do=storage على موقع vBulletin الخاص بك وقم بنقل الصور الرمزية إلى قاعدة البيانات قبل تصديرها.
انسخ نسخة الاحتياط ومجلد المرفقات إلى الجهاز الذي ستجري عليه الاستيراد (على سبيل المثال، باستخدام scp أو rsync). تظهر إعدادات مسؤول vBulletin مكان تخزين المرفقات.
الخيار أ: الاستيراد على جهاز تطوير (موصى به)
يتيح لك الاستيراد المحلي التكرار بسرعة والتخلص من المحاولات الفاشلة. عندما يبدو النتيجة صحيحة، قم بعمل نسخة احتياطية للموقع واستعدها في بيئة الإنتاج.
sudo mysql -e "CREATE DATABASE vb4"
gunzip < vb4_dump.sql.gz | sudo mysql vb4
البدء بقاعدة بيانات فارغة لـ Discourse:
bin/rails db:drop db:create db:migrate
تشغيل المستورد. يمكنك إيقافه وإعادة تشغيله في أي وقت، لأنه يتخطى المحتوى الذي تمت استيرادته بالفعل.
export DB_HOST="localhost"
export DB_NAME="vb4"
export DB_USER="root"
export DB_PW="" # كلمة مرور جذر MariaDB، إذا كنت قد عينت واحدة
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
ابدأ تشغيل Discourse ودع مهام الخلفية تنتهي. شغل bin/dev، وفي طرفية ثانية شغل bundle exec sidekiq. يمكن أن يستغرق إعادة خبز المشاركات ومعالجة الصور وقتًا طويلاً في المنتديات الكبيرة. يمكنك متابعة التقدم على http://localhost:4200/sidekiq.
الانتقال إلى الإنتاج. قم بعمل نسخة احتياطية واستعدها على موقع الإنتاج الخاص بك من خلال اتباع نقل موقع Discourse إلى VPS آخر.
انسخ نسخة الاحتياط والمرفقات إلى /var/discourse/shared/standalone/ على المضيف. تظهر الملفات داخل الحاوية تحت /shared/، وتحافظ الملفات هناك على بقائها بعد إعادة بناء الحاوية.
ادخل إلى الحاوية وقم بتثبيت MariaDB:
cd /var/discourse
./launcher enter app
apt-get update
apt-get install -y mariadb-server libmariadb-dev
service mariadb start
تثبيت أحجار كريمة المستورد:
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'
تحميل قاعدة بيانات vBulletin:
mysql -e "CREATE DATABASE vb4"
gunzip < /shared/vb4_dump.sql.gz | mysql vb4
تشغيل المستورد. شغله داخل tmux أو screen حتى لا تقتله انقطاعات اتصال SSH.
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'
التنظيف. احذف الملفات التي نسختها إلى /shared، ثم أعد بناء الحاوية. إزالة إعادة البناء لـ MariaDB والأحجار الكريمة الإضافية وتستعيد ملف Gemfile الأصلي.
exit
cd /var/discourse
./launcher rebuild app
إعدادات الموقع الموصى بها
اضبط هذه الإعدادات قبل الاستيراد. يمكنك أيضًا ضبطها في get_site_settings_for_import في script/import_scripts/base.rb، مما يساعد عندما تجري عمليات استيراد تجريبية بشكل متكرر.
login_required: قم بتفعيل هذا حتى تنتهي عملية الاستيراد وتتم مراجعتها.
slug_generation_method: اضبطه على encoded إذا كان منتداك ليس بالإنجليزية، للحفاظ على عناوين URL للموضوعات مع العناوين غير ASCII.
download_remote_images_to_local: قم بتعطيل هذا إذا كنت لا تريد أن يقوم Discourse بتنزيل الصور المرتبطة بشكل مباشر في المشاركات القديمة.
disable_system_edit_notifications: قم بتفعيل هذا بحيث لا يتم إخطار المستخدمين بكل مشاركة يعدلها النظام أثناء معالجة الصور.
مشاكل معروفة
Integer values are not supported (ArgumentError) في parse_timestamp. يؤثر هذا على النسخ القديمة من السكربت التي تعمل مع إصدارات أحدث من 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.
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?