How to backup/restore mySQL Database using PHP scripts?

By yapanitz ·
Who can help me create scripts on making a backup/restore file of mySQL database in PHP without using mySQL dump? It's like backing up the database manually.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Well if you don't want to use mysqldump

by Tony Hopkinson In reply to How to backup/restore myS ...

it's just a straight file copy/archive manouevre, usually followed by a zip.

Bash or Perl and then scheduled will be a lot easier though. If you do it through PHP that means Apache will need access to the files themselves.

Then there's do you want to shut myslql down while doing it, especially the restore.

Then there's security on calling the PHP to do it.

All solvable, but I've no idea whether it's worth the effort, becaue you haven't said why.

Look up PHP and shell commands as a start though.

Collapse -

This is what they want

by yapanitz In reply to Well if you don't want to ...

They want me to put a backup/restore on one of my page so they can backup the database anywhere they are if they are logged in as administrator. The restore would be done in the campus. Its just a small database holding not more than 100 users right now since it wasn't online yet.

Collapse -

Wow that's a tin of worms

by Tony Hopkinson In reply to This is what they want

You can do an archive and zip while the database is going, but there is a possibilty that you could get part of a transaction.
How likely that is something you'll have to look at.

Running a shell script (choose waht ever shell you are comfortable with will be way easier than writing all this in PHP.

Whatever admin means logging in to your web site, it's is necessarily the sql admin, the admin who can see the files in the my Sql folder, or the back up folder, it will be account teh apache daemon is running at that will need the required privileges, (or teh batch file if you go that way.

Ther's nothing in what you said that cuts out MySQLDump, either, that would be much easier.
kick one off then have a Cron Job, that looks for the files, tar, zip, even dump to external media...

Restoring is a whole 'nother kettle of worms, having the db active while that is happening would be nuts.

Isn't on line, yet, equals design for when it will be, otherwise it will be a temporaraily permananent solution.

Why don't they just use PhPMyAdmin by the way?

This is bass ackwards, get them or your DBa to write a script in something to do the work and then just call it from PHP.

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums