PHP Script for MySQL Backup

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

PHP Script for MySQL Backup

Post by legend986 »

My host does not provide me with Shell Access nor access to SQL Binary Logs. Is there a way I could get incremental backups of my database?
dillion
Forum Commoner
Posts: 56
Joined: Thu Feb 15, 2007 8:32 am

Post by dillion »

Are you able to write cron jobs (maybe via their control panel)?
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Yeah I think I can do that... But I'd like to know how to do it manually with a php script along with a cron :roll:
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Someone please?
User avatar
robshanks
Forum Commoner
Posts: 32
Joined: Sun Aug 05, 2007 9:27 pm
Location: Hull, UK

Post by robshanks »

You can use software - I like MySQL Auto Backup http://www.mysqlautobackup.com/

You can write a php script manualy or install phpmyadmin http://www.phpmyadmin.net/home_page/index.php and look at the php code generation features along with the export functions the software has and between the two you will be able to create a php script to back up your database to a sql file.
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Thank you so much... But did I miss out on the Incremental Backups? I couldn't find that in the features list anywhere in the first link you provided :(
User avatar
robshanks
Forum Commoner
Posts: 32
Joined: Sun Aug 05, 2007 9:27 pm
Location: Hull, UK

Post by robshanks »

I use the Pro version and it does incremental backups.

I find it good as I do an hourly clone to my backup server, 6 hourly incremental backups, and a nightly full backup, all with the software running a service on my backup server and I can basically forget it :)
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

I see its not a free script :(
User avatar
robshanks
Forum Commoner
Posts: 32
Joined: Sun Aug 05, 2007 9:27 pm
Location: Hull, UK

Post by robshanks »

No it isn't but for me I found the peace of mind worth the expense, and when the hosted server I had a customers site on went down for 12 hours during the floods here in the UK I had them up and running again in 15 minutes on my backup server.
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Well, yeah I'm sure you must be enjoying that script... But well, I'll keep searching for some free one... Thanks for all the help...
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I'm not sure, but I imagine you can still run shell commands using the exec command. It may be worth running a test, and if that's successful, using mysqldump. There's no reason why you couldn't be able to create the backup and move it into a web folder and download it over HTTP.

But as I say, I'm not sure what happens when you use exec, system or shell_exec when shell access is disabled.

Regards,
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Tried it but maybe I'm not using it right... Will keep trying that anyways...

But just for learning new things, I wanted to know this technique please...

I've seen a few scripts repeat themselves repeatedly to complete the execution. For example, they keep dumping the database onto the webserver itself, refreshing the script itself. And before each refresh, it dumps around 2000 queries or say executes for around 15 seconds and then refreshes and then resumes... I want to know how this is done... Any advice please?
Post Reply