View Single Post
Old 01-20-2006, 07:12 AM   #1 (permalink)
Bullit
 
Junior Techie

Join Date: Nov 2003

Posts: 58

Bullit

Default To use crontab to set mysql dbase backup

Hi there,
I have entered the world of cron jobs and am less than experienced!

I want to use crontab manager in my webhosting control panel to automate dbase backups...

I think this should work for a database backup:

In a db_backup.pl file: run from the crontab manager at a specific time.

/usr/bin/nice -20 /usr/bin/mysqldump -q --hdbhost.com --user=username --password=password dbname /usr/www/users/ourname/backup/database_name _`date "+%Y%m%d"`.sql ; cd /usr/www/users/ourname/backup ; /usr/bin/find *.sql -mtime +7 -delete
>/dev/null 2>&1

##comments###
# hostprovider want us to nice the task with val 10+
# -q to avoid exceeding memory lims for large tables
# host user and pass and dbname provided
# output to database_name with date.sql
# change dir to the backup folder
# delete any .sql older than 7 days
#If any output is produced by a command executed from a crontab, the cron daemon will normally email the user that output.
#thus >/dev/null 2>&1
#
#could change dir to a success_email.txt and send that email to me@myhost.com
#not sure of the syntax to do this
#how can we find out about errors?

I would value input from anyone who is familiar with this task.
I'd love a report emailed to me of success / fail etc

Cheers

database is mysql
Bullit is offline