Long-term datasets for the understanding of solar and stellar magnetic cycles