I am assuming there are too many forum nodes, hence you are not doing it from the backend.
Look at the actionSave method of XenForo_ControllerAdmin_Forum class. What you can do, is write a simple addon (or add a method to an existing addon) which queries your old database for the input data required by the actionSave method and then has the same code as the actionSave method to write the data. This would be quicker and would take care of all dependencies.