Jump to content

Using PHP to take a backup of a MySQL DB


harishkumar09

Recommended Posts

I have a phpBB forum running on H-SPHERE Control Panel. For some reason I am unable to take take the backup of the forum and my hosting provider is not being of much help either. So I was just wondering if I could just take a backup of my forum by reading all the information from the Database Tables by executing SQL queries from PHP ?

 

Is it possible ? Can I just read it off and output it to a text file and later use it to restore (duplicate) the DB tables ?

Link to comment
Share on other sites

Do you have access to your server via SSH?

 

p.s. - There is no easy way to export the data with PHP's MySQL functions. There might be some script out there that someone wrote, but I don't have one. I use the mysqldump command line tool via an SSH shell:

mysqldump --opt -h <hostname> -u <user> -p <pass> <db_name> > <backup_filename>.sql";

 

I then wrap the above command in a PHP script, which does some error checking and emails me with problems. Then, I execute that PHP script with a cronjob.

Link to comment
Share on other sites

 

That was really a very good search unidox. In fact I did try searching before posting here. Can you give me some links that teach you how to make effective searches ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.