One of the reasons for the limited applicability of predictive water quality models is the lack of data from monitoring control stations that are required as input. In this context, the main novelty of the present work is the recovery of information on the state variables present in a water quality model through measured data at a target downstream location. The reconstruction of the upstream boundary condition is the goal of the present work. For this purpose, an adjoint-state method is developed to find the sensitivities of the functional with respect to variations on the upstream boundary conditions of the model. The resolution of both forward and backward problems ensures strong, accurate and reliable solutions in both steady state and unsteady scenarios. The different cases demonstrate that the method is able to reconstruct any observed distribution with little computational effort, including the heat balance with all its external inputs.