When and where should i use backup function for backup my database?

I made my database backup function, i wanto to use this function at a time that one day in a mounth or past every 10 days, but i am not confident how to use this function automatically ,and should i call it after login?