So I just transferred all my websites (a dozen of them) to a new webhost who runs Linux:

FreeBSD 4.4-RELEASE (SERVER) #0

I have a couple of MYSQL databases for phpBB2 that I need to do daily backups of - my last host crashed and burned and I lost *EVERYTHING*, even tho they swore they were doing backups of everything. The moral of that story is "Never trust anyone to do backups for you..."

anyway, I keep hearing about "oh just run a CRON job" to back things up. Not familiar w/ CRON - I'm looking for a simple script that I can use to do this. Anyone have anything I can tweak as a starting point?

The other thing I need is a watchdog process to fire an email off to me if it detects that the MYSQL server shuts down. It shut down today for NO apparent reason. The support staff couldnt find out why either. Restarted fine but I had calls from too many people before I looked into it. would rather be proactive and know about it from the source rather from the affected.

Any help appreciated!

Jeff

http://www.porscheracingclub.com
http://www.911cup.dom
http://www.bushwacker.net
http://www.bushwacker-racing.com
http://www.herreriascellars.com

Recommended Answers

All 9 Replies

For starters, http://www.porscheracingclub.com is telling me that phpBB cannot connect to the database when I try to look at your forums. Also, http://www.911cup.dom is down.

That aside, phpBB's ACP (adminstration panel) allows you to do database back-ups and restores. A more efficient way is via phpMyAdmin if it's supported on your server. This allows you to database dumps into .sql files. However, you'll need shell access (ask your host if you have it) in order to recover the data this way.

Cron jobs are scripts scheduled to run at a particular time (e.g. do a daily back-up every night by automatically scheduling a script -- that backs up your site -- to run once every 24 hours).

Unfortunately, other than phpBB's built-in backup/recovery tool, I don't know of any other way to back-up a MySQL database without access to phpMyAdmin or shell access.

GOOD LUCK!

Thanks for noticing the db wasn't running - this is exactly what I'm talking about... the server just shuts down for no reason sometimes. Looks like I also need a watch dog process that will keep it running and restart it if it notices it stopped.

sure MYSQLAdmin works - can back up all day using that. I also have a day job thogh and would rather not have to remember to do manual backups. I have shell access to the db directory and have the privelages to be able to run cron jobs, hence my desire to create them! I was hoping someone had already cracked these nuts and I wouldnt have to spend an entire evening recreating work!

Jeff

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

I'm using this on techtalkforums.com and it works nicely :)
Hope this helps. Enjoy!

awesome! that works great! thanks again.

Jeff

Don't forget to create the cron job to:

1. Check to see if MySQL is running, and if not, to start it.
2. Run the script that performs the backup job.

This is a sample crontab entry for FreeBSD (which is what your server is running) that checks to see if MySQL is running (if it's not, it starts it) and does the backup:

*/15 * * * * your_userid /path/to/mysql startup_options
* 23 * * * your_userid /path/to/backup/script

The first line checks every 15 minutes to see if MySQL is running, and starts it if it's not

The second line runs the backup script every night at 11:00 PM.

The syntax for cron is:
minute hour day month wday user command

Also, the line that identified this system as FreeBSD is this:

FreeBSD 4.4-RELEASE (SERVER) #0

You can check the FreeBSD handbook for more info on using cron:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/configtuning-cron.html

Hope this helps.

I realize this is an old post but I have a similar question. In RedHat, what and where can I set a cron job up to run a *.sh script - specifically, my database backup script shown above.

I realize this is an old post but I have a similar question. In RedHat, what and where can I set a cron job up to run a *.sh script - specifically, my database backup script shown above.

sh name the script.sh

If the script has exe perms do

./name the script.sh

Examples how to set cron:
http://www.webmasters-central.com/t/cron.shtml

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

Thanks for noticing the db wasn't running - this is exactly what I'm talking about... the server just shuts down for no reason sometimes. Looks like I also need a watch dog process that will keep it running and restart it if it notices it stopped.

sure MYSQLAdmin works - can back up all day using that. I also have a day job thogh and would rather not have to remember to do manual backups. I have shell access to the db directory and have the privelages to be able to run cron jobs, hence my desire to create them! I was hoping someone had already cracked these nuts and I wouldnt have to spend an entire evening recreating work!

Jeff

Hi,

If you find yourself in a position were your host does not have cron support, then use http://www.webbasedcron.co.uk
You can set a cron job from here to backup your database.

Good luck,
papayiya

Man, this thread is more than 1 year old...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.