By Thierry.Lefort
via davidwalsh.name
Published: Aug 19 2008 / 03:23
One of the most important tasks any developer needs to do often is back up their MySQL database. In many cases, the database is what drives most of the site. While most web hosts do a daily backup of a customer's database, relying on them to make backups and provide them at no cost is risky to say the least. That's why I've created a database backup function that I can call whenever I want — including nightly CRONs.
Comments
dmitryx replied ago:
why would i want to run __php__ script from cron? instead of mysqldump?
you are strange people, trying to invent the wheel.
dmitryx replied ago:
god, every day reading dzone i realize how cool i am.
these people call themselves a 'developers'.
fluminis replied ago:
well, mysqldump is not accessible on several hosting services, while the script run well on those servers.
Excecuting a shell command is not always possible (due to php configuration) and you are not always admin of your server so you may not be able to change the configuration.
So : do not invent the wheel if you can call mysqldump.
Use this script if you can do anything else.
I remember using the site "webcron.org" to call a php script on my web site to run a script like this one. I could not set up a cron nor using mysqldump on that server...
And why to use php for cron ? To re-use classes and functions you use on your website not to re-invent the wheel in a script shell!
dmitryx replied ago:
>>well, mysqldump is not accessible on several hosting services, while the script run well on those servers.
Yeah, they usually provide you cron access on "those servers". If hosting company provides you with tools to set your cron scheduling its common that they also provide you with database backup utilities (which is mysqldump again behind nice interface)
>>Excecuting a shell command is not always possible (due to php configuration)
Have it ever occured to you that you dont need php to execute shell command?
>> I could not set up a cron nor using mysqldump on that server...
Change hosting provider then. Anyway, you said you need this script in order to schedule backups. Otherwise phpmyadmin can do better. Your point?
>>To re-use classes and functions you use on your website not to re-invent the wheel in a script shell!
Oh boy... So, re-using custom php is re-using, while using mysqldump (which is bundled) is inventing, right? Hilarious.
Not mentioning the fact, that if you dont trust your hosting company with backups - you can get a dedicated server and set it up by yourself.
mikamtb31 replied ago:
Dmitrx,
There's no reason to bash the script. It's still very much valid and useful.
Maybe you're a good technical programmer, but I certainly wouldn't want to work with you.
Voters For This Link (13)
Voters Against This Link (1)