Simple script for configure failover Internet and VPN connections in MikroTik.
/system script
add comment=ISP1 dont-require-permissions=no name=isp1 owner=admin policy=read,write source="/ip ipsec policy enable 1\r\
\n/ip ipsec policy enable 2\r\
\n/ip ipsec policy disable 3\r\
\n/ip ipsec policy disable 4\r\
\n/ip route set [find where dst-address=0.0.0.0/0 and gateway=1.2.3.4] distance=10"