Firstly, I'm new here so don't be too harsh if I get something wrong, please just inform me of the right thing to do. I'm a second-year engineering student in New Zealand.
I am using a DS3231 Real Time Clock module on a custom PCB with an ATMega328P to keep the time in a system that may be powered up a handful of times per year. Most of the time, when the microprocessor and board do not have power, the RTC will keep its time with a 3V 2032 coin cell battery. Other people state this battery lasts ~2 years, but I want mine to last much longer. I, therefore, want to charge the backup battery when the board is powered. I am thinking of using the TP4056 charger, but I want to charge the battery in place on the board. When the battery is being charged, the RTC is powered by the board. I have attached my thoughts on a schematic with a Schottky diode (D1) between the charger and the battery. Is this diode necessary or the best option? I have also attached the datasheets. 5V and 3.3V are both from regulated supplies powered by a 24V plug. This 5V is the same as that powers the ATMega.