need help w/ CRON job for backups

Reply

Join Date: Jul 2003
Posts: 3
Reputation: jeffstev is an unknown quantity at this point 
Solved Threads: 0
jeffstev jeffstev is offline Offline
Newbie Poster

need help w/ CRON job for backups

 
0
  #1
Jul 11th, 2003
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,036
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb
 
0
  #2
Jul 11th, 2003
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!
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jul 2003
Posts: 3
Reputation: jeffstev is an unknown quantity at this point 
Solved Threads: 0
jeffstev jeffstev is offline Offline
Newbie Poster

Re: need help w/ CRON job for backups

 
0
  #3
Jul 11th, 2003
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,036
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: need help w/ CRON job for backups

 
0
  #4
Jul 12th, 2003
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!
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jul 2003
Posts: 3
Reputation: jeffstev is an unknown quantity at this point 
Solved Threads: 0
jeffstev jeffstev is offline Offline
Newbie Poster

Re: need help w/ CRON job for backups

 
0
  #5
Jul 12th, 2003
awesome! that works great! thanks again.

Jeff
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 372
Reputation: TheOgre is a jewel in the rough TheOgre is a jewel in the rough TheOgre is a jewel in the rough 
Solved Threads: 6
TheOgre's Avatar
TheOgre TheOgre is offline Offline
Posting Whiz
 
0
  #6
Aug 7th, 2003
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.ISO...ning-cron.html

Hope this helps.
If you spend more on coffee than on IT security, you will be hacked.
What's more, you deserve to be hacked.
-- former White House cybersecurity czar Richard Clarke
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,036
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: need help w/ CRON job for backups

 
0
  #7
Jan 12th, 2004
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.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Oct 2003
Posts: 766
Reputation: )BIG"B"Affleck can only hope to improve 
Solved Threads: 6
)BIG"B"Affleck's Avatar
)BIG"B"Affleck )BIG"B"Affleck is offline Offline
Banned

Re: need help w/ CRON job for backups

 
0
  #8
Jan 12th, 2004
Originally Posted by cscgal
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
Last edited by )BIG"B"Affleck; Jan 12th, 2004 at 12:48 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1
Reputation: papayiya is an unknown quantity at this point 
Solved Threads: 0
papayiya papayiya is offline Offline
Newbie Poster

Re: need help w/ CRON job for backups

 
0
  #9
Feb 21st, 2005
Originally Posted by jeffstev
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: need help w/ CRON job for backups

 
0
  #10
Feb 21st, 2005
Man, this thread is more than 1 year old...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the *nix Software Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC