I think I already posted this, but here is a great tutorial:
http://www.phpfreaks.com/tutorials/28/0.php
On the other hand if you really want to automate backups, use a Tool called "DARKMANS SITE BACKUP TOOL" it is really the BEST I have used and it not only backs up your Database, it works for specific directories as well, and it backs up everything to a folder on your server and it can even send it via email, after compresion if you like.
FIVE STAR RECOMMEND
Here is the link:
http://www.crohack-forum.com/forum/viewforum.php?f=18
It will make your life alot easier.