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.


  • Admin

    @codecowboy You'll probably want to mongodump and then mongorestore. You only need to dump and restore the objects collection.



  • I just did this. Restoring mongodb & trying to run ./nodebb setup is no good. Just copy over your old forums files and modify the config file if necessary (ip of mongodb, user/pass if changed).



  • @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 thanks - that worked for me in the end.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.