If the your circuit is always on everyday, you can increase or decrease the clock of rtc as much as the deviation.
From your problem, please do this calibration process e.g. at 0:00:06 AM. If you do the calibration when it's at 0:00:00 AM, then the clock 11:59:55 PM and when it becomes 00:00:00 AM, the clock will be calibrated once again, continuously.
Use a RTC ram memory to note that the calibration has or has not done today. and each clock reaches 0:00:00 AM, this value should be cleared. After the calibration process at 0:00:06 AM, set this value, so that when 5 seconds later (when the clock is 0:00:06) calibration process will not be done. (check this memory before do the calibration process)
But if your circuit is not always on everyday, then you need to perform addition or subtraction method based on date of the last calibration. eg date of last calibration is 09/01 and then the clock is turned off for 2 days. then at the 09/03, time should be subtracted as much as 10 seconds (2 days x 5 second/days). and then save last calibration date (09/03) at the RTC RAM. for this method, calibration may not be performed starting from 11:00:00 PM to 1:00:00 AM to prevent possible as the previous method.
The better way, replace it with TCXO RTC (DS3231 or DS3232)
Arch Zone