You can also see some details at Moving a NodeBB mongo DB from one server to another.
Transfer host to new server
I was wondering if there is any working way to transfer an existing NodeBB site to a new host, without losing any data. I've seen some posts on here regarding the same thing but they are considerably dated so I didn't know if there if there is any good way to do it for a recent installation.
@Kolt-L I would do something along the following:
- Get everything ready/tested on the new host.
- Backup database, e.g. mongodump, and user uploads dirs on the old site.
- Dump/drop db on the new host and restore w/actual data from #2 above.
- Repopulate nodebb uploads dirs on the new host from #2 above.
- Update DNS Zone record - see below.
- Pull plug on old
- Plug in the new.
How fast the change propagates thru the net involve some DNS admin planning:
Presuming you have access to the DNS for the domain:
- Shorten the zone's TTL to something like 1h a day or two ahead of time, depending on existing TTL.
- Update the zone record - transition to new site.
- Monitor real close like and if goes awry role back real quick like. So have your DNS accessible.
- All goes well, update TTL on your zone's record to something more reasonable, e.g. 24-48hr.
Edit: Oh yeah, in case not obvious, you're going to want to put the old site in "Maintenance Mode" while your transitioning, lest you risk loosing some posts.
@Kolt-L It depends on your set up details, of which I know not. But maybe resembles something like:
mongodump -u <your mongo user here> -p <your mongo user pass here> --out /where/you/want/the/backup/files/$(date +%F) --authenticationDatabase=admin
If, perchance ye' followed the nodebb docs for setting up mongodb here https://docs.nodebb.org/configuring/databases/mongo/ and here https://docs.nodebb.org/installing/os/ubuntu/ then you should have an admin user. Hopefully you still have that pass tucked away safe somewhere.
/where/you/want/the/backup/files/$(date +%F) should now be populated with sub directories for each of the admin and nodebb databases. Ensure you copy them both to the new server.
For future reference, I prefer not to have my privileged admin user running cron scripts so I created a "backup operator" user with limited privileges for such duties. YMMV.
Note: You may need to quote the pass phrase if it contains special characters.