PHP Classes

Danen MySQL Backup: Create database backup SQL statements using MySQLi

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 511 All time: 5,760 This week: 455Up
Version License PHP version Categories
danen-mysql-backup 2Freely Distributable5.4PHP 5, Databases, Systems administration
Description 

Author

This class can create database backup SQL statements using MySQLi.

It can connect to a MySQL database table using the MySQLi extension and generates a file with SQL statements that can be used later to restore the table definition and record data of one or more database tables.

The class creates a backup file with a unique name and returns the backup file name.

Picture of Gerry Danen
  Performance   Level  
Name: Gerry Danen <contact>
Classes: 3 packages by
Country: Australia Australia
Age: 74
All time rank: 219632 in Australia Australia
Week rank: 295 Up2 in Australia Australia Up

Recommendations

Good backup/restore MySQL
Script to backup and restore databases

Example

<?php
// example to do a full database backup

require_once 'danenMysqlBackup.class.php';


$B = new danenMysqlBackup();

$backupSqlFile = $B->backupStart();

if (
$backupSqlFile )
{
   
$backupSqlFile = basename( $backupSqlFile );
    echo
"Created: $backupSqlFile";
}
else
    echo
"ERROR: backup failed.";



Details

I needed a MySQL database backup function that I could call from a script and would not rely on mysqldump or phpMyAdmin. I found a class by Hossein Sarlak that used the older mysql interface. I wanted the newer mysqli interface, so I set out rebuilding the class when I could not locate Hossein Sarlak. I found his script for sale for $25, but no indication whether it was updated. This script is free. Use as you see fit. Make sure to read all comments. There are some customizations needed. Gerry Danen 26 February 2015

  Files folder image Files  
File Role Description
Plain text file danenMysqlBackup.class.php Class Main class file
Accessible without login Plain text file doBackup.php Example Shows how to call the class
Accessible without login Plain text file readme.txt Doc. Some extra information

 Version Control Unique User Downloads Download Rankings  
 0%
Total:511
This week:0
All time:5,760
This week:455Up