Working as a freelancer I came across several projects where the clients' has lost all their users because their databases was destroyed by some sort of attack like:-
Websites coding doesn't get affected much. But all we lose is our database where various users register daily with the hope of staying connected with you. If they subscribed to your email notification whenever you post something new... then what? Your goodwill compels some users to register and subscribe again..but various will not do that again... Why are we even discussing this if we have a simple solution for that. Thanks to a cronjob. ????
So, depending on how much traffic your website gets daily you can schedule a cronjob for every minute, hour, month, etc. (We can run many cronjobs parallelly. So don't worry about it).
If you just want to run backup command then can use this method. But is considered an insecure way of writing because you are revealing the password in the command you wrote. So I prefer the second method.