Hey guys so after trying for a week or so I decided to import the database on docker app which I hoped it will succeed without any issues. TBH I got some issues at first but it turned to be all easy to solve.
Now I would recommend doing this only once before you deploy your production site, after importing everything take a Discourse backup, wipe everything out and install new Discourse instance then restore the imported db.
Ok let’s begin:
-
First lets backup your old database from your old server, sign in to your Discourse server then:
ssh USER@XENFORO_SERVER_IP # Use -p argument to specify custom port mysqldump -u XENFORO_DATABASE_USER -p XENFORO_DATABASE_NAME > xen_db.sql exit
-
After installing Discourse start the app:
./launcher start app
-
Now lets pull the database backup from xenforo server:
scp USER@XENFORO_SERVER_IP:~/xen_db.sql /var/discourse/shared/standalone/xen_db.sql
If you changed the ssh port use -P argument
scp -P 2222 USER@XENFORO_SERVER_IP:~/xen_db.sql /var/discourse/shared/standalone/xen_db.sql
-
Login to docker machine, install and start mysql:
docker exec -it app bash sudo apt-get update sudo apt-get upgrade
During the installation you will be asked to set a root password for mysql
sudo apt-get install mysql-server mysql-client libmysqlclient-dev service mysql start
-
Login to mysql and create new database:
mysql -u root -p
Enter your mysql root password then
create database xenforo_db; exit;
-
Import your xenforo database into the new one:
mysql -u root -p xenforo_db < /shared/xen_db.sql # Enter your mysql root password and wait until it finish
-
Include the gem in discourse Gemfile:
echo "gem 'mysql2'" >>Gemfile
-
Run bundle install:
bundle install --no-deployment
-
Edit the importer script and change the following:
vi /var/www/discourse/script/import_scripts/xenforo.rb XENFORO_DB = "xenforo_db" @client = Mysql2::Client.new( host: "localhost", username: "root", password: "Your mysql root password", database: XENFORO_DB )
-
You are set to go now, run the importer:
RAILS_ENV=production bundle exec ruby script/import_scripts/xenforo.rb
-
If you get the error
'Peer authentication failed for user "discourse"'
: -
Edit the file
/etc/postgresql/9.5/main/pg_hba.conf
-
change all ‘peer’ to ‘trust’ and save the file
-
restart postgres server:
service postgresql restart
Run the importer again and this time it should work without any problem, be patient this might take a while based on your database size.
Hope this helps someone.