Moving a NodeBB mongo DB from one server to another.
-
Re: Moving a NodeBB Install from one server to another.
I'd like to migrate a NodeBB mongo database from one server to another. Does this have to be a fresh install or can it work from
./nodebb setup
? I tried the latter and entered the full path to mongo json files but it has not imported them.@Scuzz can you elaborate on the procedure? You mentioned it in the post linked above.
-
@julian thanks. I managed to restore the database but I have messed things up as I thought I would try and be secure and add a username/password within mongo.
Is there a way to specifify the authentication database here ?
"url": "http://localhost:4567", "secret": "****", "database": "mongo", "mongo": { "host": "127.0.0.1", "port": "27017", "username": "***", "password": "****", "database": "0" }
I added the user to the admin database like this:
db.createUser( { user:"****", pwd:"****", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] })
My NodeBB database is
0
@L33t why is it 'no good' ?
-
@codecowboy said:
@julian thanks. I managed to restore the database but I have messed things up as I thought I would try and be secure and add a username/password within mongo.
Is there a way to specifify the authentication database here ?
"url": "http://localhost:4567", "secret": "****", "database": "mongo", "mongo": { "host": "127.0.0.1", "port": "27017", "username": "***", "password": "****", "database": "0" }
I added the user to the admin database like this:
{ user:"****", pwd:"****", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] })
My NodeBB database is
0
@L33t why is it 'no good' ?
The authentication database should be the same database as your forum database. You just add a user to it in the mongo cli.
It's no good because it won't let you run the setup. If I remember right, it errors out and says it can't create the records it needs or something. It's easiest to just restore and copy over files and I'm not sure if there really is another way.
-
I have a script that does daily backups for me. I copied the most recent one to the new server.
Restored it using mongorestore or whatever the command is to restore mongo databases. It's been a while so the commands are not fresh in my head.Once the database has been restored correctly you can run the NodeBB installer.
When it asks for the database you will just tell it the database name of the database you just restored.
This should then install NodeBB with your old database.
Unless something has changed with the later versions of NodeBB then this procedure should work.
-
@scuzz said in Moving a NodeBB mongo DB from one server to another.:
Once the database has been restored correctly you can run the NodeBB installer.
When it asks for the database you will just tell it the database name of the database you just restored.
This should then install NodeBB with your old database.
Yes, this has worked for me as well.
Making a backup of the nodebb database on the old server, for example:
mongodump -u nodebb -p [password] -d nodebb -o dump/nodebb-2018-03-30
Restoring the nodebb database from that backup, after copying it to the new server:
mongorestore -u nodebb -p [password] -d nodebb dump/nodebb-2018-03-30/nodebb/
And then installing NodeBB on the new server.