We have PostGreSQL database configured on two machines for replication in master slave mode. On failover of the database, the slave becomes master.
During the process of restoring the database on the primary machine, one need to copy the latest copy of the database from the standby machine.

Before copying, one needs to check whether the database on the standby machine is more latest than the one on primary.
I am looking for ways to check which database is latest.
There is one command pg_controldata that dumps the statistics about the pg_control file. This contains the latest checkpoint and checkpoint timestamp.
Is there a way to get this information from remote machine.

Please let me know how we can determine the latest database among two databases.

Thanks and Regards,