Backup MySql DB with PHP

  • cancer10
  • Proficient
  • Proficient
  • cancer10
  • Posts: 268

Post 3+ Months Ago

Hi,

Is there any PHP script available that would take a complete backup of my database?

I have googled for this several times and everytime either I come up with a script that only takes data backup and not the db structure OR a script that uses mysqldump command (since my client is on a shared server, hence he is not authorized to run the execute command on his server),

So was wondering if there is a script that actually takes a complete backup of the db and not using the mysqldump command?


Thanx so much for your help.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Is phpMyAdmin an option ?
Using the "Export" tab you can export table schemes and data.

If you've got something for data already and you don't mind taking a minute to parse some output from MySQL, you can use SHOW COLUMNS to get the table schema from the database.

Code: [ Select ]
mysql> help show columns
Name: 'SHOW COLUMNS'
Description:
Syntax:
SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name]
    [LIKE 'pattern' | WHERE expr]
 
SHOW COLUMNS displays information about the columns in a given table.
It also works for views as of MySQL 5.0.1. The LIKE clause, if present,
indicates which column names to match. The WHERE clause can be given to
select rows using more general conditions, as discussed in
http://dev.mysql.com/doc/refman/5.0/en/ ... -show.html.
 
...
 
The FULL keyword causes the output to include the privileges you have
as well as any per-column comments for each column.
 
...
 
URL: http://dev.mysql.com/doc/refman/5.0/en/ ... lumns.html
  1. mysql> help show columns
  2. Name: 'SHOW COLUMNS'
  3. Description:
  4. Syntax:
  5. SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name]
  6.     [LIKE 'pattern' | WHERE expr]
  7.  
  8. SHOW COLUMNS displays information about the columns in a given table.
  9. It also works for views as of MySQL 5.0.1. The LIKE clause, if present,
  10. indicates which column names to match. The WHERE clause can be given to
  11. select rows using more general conditions, as discussed in
  12. http://dev.mysql.com/doc/refman/5.0/en/ ... -show.html.
  13.  
  14. ...
  15.  
  16. The FULL keyword causes the output to include the privileges you have
  17. as well as any per-column comments for each column.
  18.  
  19. ...
  20.  
  21. URL: http://dev.mysql.com/doc/refman/5.0/en/ ... lumns.html
  • cancer10
  • Proficient
  • Proficient
  • cancer10
  • Posts: 268

Post 3+ Months Ago

Question:

Q1) Does phpmyadmin uses exec() command when you export backup?

Q2) My client has phpmyadmin running on his hosting account, does that mean he is allowed to use the exec() command?


Thanx
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Q1) I don't know and it would take me at least an hour to dig through the code to find out. I would bet against it doing so though.

Q2) Impossible to tell without an answer to Q1.

If it's already installed, I suggest trying out the export tab.

Attachments:
phpmyadmin.png
  • cancer10
  • Proficient
  • Proficient
  • cancer10
  • Posts: 268

Post 3+ Months Ago

Hi

Thanx for ur reply.

The problem is that my client wants a db backup with just a simple click of a button. This is the reason I cannot have him do that under phpmyadmin


thanx
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Does this client have access to cron jobs/tabs ?

You should be able to setup automated backups using it and Mysqldump if they do.
  • cancer10
  • Proficient
  • Proficient
  • cancer10
  • Posts: 268

Post 3+ Months Ago

Nope, its a shared host with limited features.
  • cancer10
  • Proficient
  • Proficient
  • cancer10
  • Posts: 268

Post 3+ Months Ago

Hey,

Apart from a FULL backup script, I also want a script that takes incremental backups. Any such available?


Sorry for asking too much :)
  • Truce
  • Guru
  • Guru
  • Truce
  • Posts: 1477
  • Loc: Washington DC

Post 3+ Months Ago

cancer10 wrote:
Hey,

Apart from a FULL backup script, I also want a script that takes incremental backups. Any such available?


Sorry for asking too much :)


If he's your client, shouldn't YOU be doing the work that you billed him for?

To point you in the right direction:
  • Learn how to form proper MySQL queries and about how to retrieve the table structure from the database.
  • Dive into the code of phpMyAdmin and see how they're formatting the output/backup files.
  • Code something similar up to suit your needs.

Incremental backups? Are you sure you're not looking for automatic recurring backups? Incremental backups are going to leave your client with several files that all have to be used to restore the database in case something goes wrong. That's not cool.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 125 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.