Okay, me again. I don't want to be secretive, so here's my solution for
my situation. You may find this useful.
My cronjobs:
(I have a lot of cronjobs and have used comments to visually structure
the crontab file. What you see is only a part.)
############################################
# delete
# all backups older than 30 days
# each night at 3:00
#
0 3 * * * find /path/to/your/webspace/website_folder/protected_folder/
backups -ctime +30 -exec rm -f {} \;
#
############################################
# write
# a database backup
# each night at 3:20
#
20 3 * * * /path/to/your/webspace/website_folder/protected_folder/
cronjob_subfolder/dailydump.sh
############################################
The file "dailydump.sh":
#!/bin/sh
DATENAME=`date +%Y%m%d`
BASENAME="/path/to/your/webspace/website_folder/protected_folder/backups/
db_${DATENAME}.sql"
/usr/bin/mysqldump -hdatabaseserver -udatabaseuser -pdatabasepassword
databasename > ${BASENAME}
I hope the mail program does not break the lines. Each of the two cron
instruction is one line, and the .sh file consists of four lines. And
please note "-h" (for "host"), "-u" and "-p" in
front of the host
address, username and password _without_ space!
Adapt and enjoy!