PDA

View Full Version : Automated backup (CRON job) anyone?



dagr
12-05-2006, 07:14 AM
Hi,

I would like to implement my own daily backup, mainly of the MySQL database, and keep a copy of it on the server, and possibly email it to me if size permits.

Ideally, I'd like to have a copy for each day of the week that would overwrite after 1 week; i.e., I would have:
...../backup/sql_MON ....../backup/sql_TUE ......./backup/sql_WED

(a total of 7 files at any one time).

Does anyone have such a script (or something similar), or if not, what LINUX commands would be involved (mysqldump ?).

Thanks
David.

Gixxer
12-07-2006, 08:26 AM
Hi,

I would like to implement my own daily backup, mainly of the MySQL database, and keep a copy of it on the server, and possibly email it to me if size permits.

Ideally, I'd like to have a copy for each day of the week that would overwrite after 1 week; i.e., I would have:
...../backup/sql_MON ....../backup/sql_TUE ......./backup/sql_WED

(a total of 7 files at any one time).

Does anyone have such a script (or something similar), or if not, what LINUX commands would be involved (mysqldump ?).

Thanks
David.
Google'd it!

http://sourceforge.net/projects/automysqlbackup/
http://www.debianhelp.co.uk/mysqlscript.htm

I've got an answer for you. If you have shell access, create a file called database_backup.sh and also an empty directory called mysql_backup

database_backup.sh script should have the following info



#!/bin/sh

date=`date '+%m-%d-%y'`
mysqldump -u database_username -pdatabase_password database_name > ~/mysql_backup/database_name.$date


Set this script up to run every night, etc. as a cron job. What it will do is save an sql dump of your database every night in the mysql_backup folder. The names of the sql dump will be something like this:

database.07-01.03
database.07-02-03
database.07-03-03

dagr
12-09-2006, 09:50 AM
Many thanks Gixxer.

I don't have shell access (does anyone?), but I'll try out the suggestions you gave with cron tool.

Cheers
David.

Gixxer
12-12-2006, 11:38 AM
Many thanks Gixxer.

I don't have shell access (does anyone?), but I'll try out the suggestions you gave with cron tool.

Cheers
David.
If you're on BH you most certainly do have SSH access.

http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=203
http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=228
http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=329

rachidheffels
01-26-2007, 03:18 AM
I'm currently trying out Backup2Mail v0.1b
A PHP script, so no shell access needed :rolleyes:

http://www.maratz.com/blog/archives/2005/06/05/send-database-backup-to-your-mailbox-with-backup2mail/