script for router failover

hi
i had a problem with VRRP and i decide to do my thing with script
i have 2 router and one of them is the primary one and the other is my backup… they have both the exact connections to uplink and downlink physically.
I want the backup one sync with the primiary and get configuration changes every 10 min and its interfaces be shutdown, and it ping the primiary, then when it got 9 fail ping it turn on its interfaces
so its like VRRP some ways
anyone can help me to write this script???