Click to See Complete Forum and Search --> : [RESOLVED] looking for advice on db backups


VisionsOfCody
02-28-2007, 05:59 AM
Hi

I take care of a number of small sites - a lot of which have small databases for news, prices etc

what i'd like to do is be able to make daily backups of all the dbs and save the backup files onto a separate server - the problem is that the sites are all on shared hosting and cron jobs are not possible

so I've been thinking of doing it like this:

on my server I set up a page that has a lot of iframes - each iframe will load a php page which is located on each different site server. when the php page is called it will receive a kind of key as a GET variable which will then authorize it to dump the database and ftp it to my own server (also shared hosting). Any errors will then be displayed in the iframe.

does this sound ok to you ?
or does it sound like a security risk ?
and could there possibly be a problem with my server receiving maybe 10 or 12 simultaneous ftp connections ?

thanks for any advice you can give

etully
02-28-2007, 09:17 AM
Your solution will work. It's maybe not the most elegant solution but when you're talking about cheap shared hosting that doesn't offer cron, you often have to abandon elegant.

To avoid the iFrames, you could set up cron on your own server to either (A) invoke wget to trigger the PHP scripts on the remote shared hosting sites, or (B) invoke one PHP script locally that uses fopen (or similar) command to trigger all the PHP scripts on the remote sites.

VisionsOfCody
02-28-2007, 10:37 AM
or (B) invoke one PHP script locally that uses fopen (or similar) command to trigger all the PHP scripts on the remote sites.

wow, I'd never heard of wget - Ive just googled it and it looks just the ticket - the only thing is I'm not sure how I would return any sql dump errors back to my php "trigger" page - the example i saw ( http://www.zend.com/tips/tips.php?id=91&single=1 ) was for doing ftp and with my low-ish level of php skills I can't work out (I'm really pushed for time, too!!) - so I think I'll go with simple and nasty and use iframes

thanks for that, though - something to check out when I get 5 mins

etully
02-28-2007, 11:13 AM
This is how I'd do it: wget on your local machine triggers a php script on the remote shared host. Essentially, it's just giving you cron. Period.

Then the PHP script on the remote machine triggers the mysqldump. If it's a success, then it sends an email to you with a subject line: "SUCCESS www.domain1.com - mysqldump". If it fails, then it sends an email to you with a subject line: "FAIL www.domain1.com - mysqldump"

That way, you don't have to sit down at your machine to perform the dump. It continues working even when you're on vacation. You could even have the failure emails sent to your cell phone while success goes to your regular mail.

I know it's extra work. It's worth it when it's all done. You'll thank yourself for taking the extra time. I mean, truthfully, you have to write the remote PHP script (which you were going to have in an iFrame) perform the dump and FTP the resulting file somewhere. That's the hard part. Writing a wget cron is one line of code. It's probably 20 mins of work the first time you do it and then 30 seconds for each extra time. You were going to write a page with a bunch of iFrames... that was going to be 20 mins of work anyway. I don't see this as very much harder and it's a good skill to have. Come on, everybody's doing it. :)

VisionsOfCody
02-28-2007, 02:15 PM
hehe - you're right - and I like the idea of the mailing thing

better get down to it then :))

cheers