How to export and import MongoDB database completely from old server to new one?



  • Hello,

    My website https://pythonforum.ir is currently working on the current server fine, but I want to migrate it to another server (from Germany to Iran).
    I somehow reached success, but it's not complete I think.
    I use mongodump command to backup all databases of the old server (admin and nodebb). I make a zip archive file of /root/nodebb/ path to make backup of everything.
    Now I transfer them into the Iran server 185.18.215.223.
    When I use mongorestore command to restore /root/dump/ that contains two folders "admin" and "nodebb", it shows me that it is restored but I see that it's not done completely.

    For example, in admin panel of the old server, I see the logs of unique visitors and things like this, but in the new server I do not see that.
    Also I see almost none of the settings have been imported. Things like in http://pythonforum.ir/admin/settings/general are not imported (none of them), but my categories do exist in the new server.

    My old server expires in two days (17th September is the expiration date).

    Would you please help me how may I migrate it without any loss of data?

    Thanks in advance


  • Global Moderator

    How did you install NodeBB on the new server?



  • Hello,

    I installed it by https://docs.nodebb.org/installing/os/ubuntu/ link (fresh install).


  • Global Moderator

    Can you describe what steps you took after the clean install to restore your database? It's my guess that restoring over the fresh db from the clean install may be the source of your issues.



  • Hello,
    Thanks, I guess so, but I don't know my wrong.

    I disabled authorization in mongodb.conf in order to mongodb let me restore the file.
    It restored but I saw some duplicate key entry errors in the screen (if needed, I can remove nodebb database in the new server to see the errors).
    I use mongo command to switch to nodebb database and drop it completely, now when I use show dbs, I see admin, local,config.

    That's what I did to restore database.



  • @PitaJ said in How to export and import MongoDB database completely from old server to new one?:

    Can you describe what steps you took after the clean install to restore your database? It's my guess that restoring over the fresh db from the clean install may be the source of your issues.

    If you set my domain to Iran IP in your hosts file, you would see the differences.
    Also I should note that in my old server, requests are all set to 443, but in new server it just works with port 80 and I have not yet installed Let's Encrypt in the new server.


  • Global Moderator

    Please try dropping all dbs in your new mongo install. Then try the mongorestore process again. See if that works.



  • Hello,

    I dropped all dbs (nodebb, local, config) and the ran mongorestore dump/ and it restored without warning or errors, but I still have issue.

    Also when I restart mongod, it fails now and it cannot connect to database. I think I should re-install it because I did not find a solution to fix it (database not running now).

    My question: would it work if beside restoring by mongorestore, I copy all files of /var/lib/mongod/ from old server to new one?


Log in to reply
 

Suggested Topics

  • 3
  • 6
  • 1
  • 1
  • 1
| |