Ten Ways to Use PHP On Your Website

eLearning Series

Customer Paradigm
888.772.0777
303.499.9318

PHP can be used to easily back up a database from a website. This week's PHP tip shows how. Read more below >>

Ten Ways to Use PHP On Your Website
Tip #10: Use PHP To Back Up A Database From Your Site

Backing Things Up

Most websites these days use one or more databases to organize pages, maintain an ecommerce shopping cart, or even have a dealer locator system.

With a content management system or a database-driven site, the database is the critical component that stores your information. Most web servers will do a backup of the whole system each day, but sometimes it can be difficult to extract or recover the mySQL database. Plus, most of these backup systems are often attached directly to the server. If the server fails or the datacenter has an outage, your data can't be easily accessed.

With PHP, one of the things you can easily do is create an automated script that each day (or even more frequently) takes a copy of the database and backs it up to another webserver.

How does this work from a technical perspective?

PHP can create a backup of a database (or just selected tables) in three easy steps:

  • A cron task tells the script to execute (perhaps once a day at a set time of the day).

    Here's a copy of the how the database looks on the web server:
    mySQL database table
  • The PHP script creates what is called a mySQL dump file. Essentially, this is a text file that makes it very easy to recreate the database.

    Here's a sample of a mySQL dump file:
    mySQL dump file
  • The php system then opens a secure FTP (file transport protocol) connection to the other server, and uploads this backup file to a folder. The system can also sends a confirmation email, usually by connecting to sendmail, that lets you know that the system was backed up properly.

    Here's a copy of a sample confirmation email from our system:

Why should I bother using PHP to back up databases from my website?

Once it's in place, it gives you peace of mind knowing that your data is safe and secure on a remote server.

 

I hope you enjoyed this 9th part of the series. Let me know if you'd like to explore how php can take your website to the next level of interactivity.

Talk to you soon,

Jeff FinkelsteinFounder, Customer Paradigm

Jeff Finkelstein

Founder, Customer Paradigm

Connect Via Facebook >>
Connect Via Linked In >>

We love referrals! Our Referral Promise >>

Customer Paradigm
5353 Manhattan Circle, Suite 103
Boulder, Colorado 80303
Visit our Website
direct 303.499.9318
fax 303.374.6104
toll free 888.772.0777
Web & Print Design · Programming · Email Newsletters · Search Engine Marketing · eCommerce

 

<< back to list of Ten Ways to Use PHP Programming on Your Website

Sign Up to Receive these Strategies in your Inbox:

  • Please fill out the form on this page to sign up.
    The emails usually go out on Friday mornings.

Please have someone contact me regarding these strategies:

First Name :
Last Name :
Phone :
Email :
Comments :
 
  Word Verification:
  Enter the word as it is
shown in the box to the right.

 This step is required to prevent abuse of our services.