PHP Backup MySQL Database Automatically: Backup and restore MySQL database dumping SQL file

Recommend this page to a friend!
  Info   Documentation   View files (18)   Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-10-10 (9 months ago) Not yet rated by the usersTotal: 265 All time: 7,632 This week: 247
Version License PHP version Categories
db-backup-restore 1.0.0Custom (specified...5PHP 5, Databases, Systems administration
Description Author

This class can backup and restore MySQL database dumping SQL file.

It takes the name of a given MySQL database and connects to a database server using MySQLi. Then it generates a file with SQL statements that can be used later to recreate the database SQL statements in case the it is necessary.

The class can also read a file previously generated by this class, so it can restore the tables and records of a MySQL database that was run the backup process described above.


MySQL Database Backup/Restore scripts
I want PHP scripts to backup and restore MySQL database on a Mac

Picture of Zacchaeus Bolaji
  Performance   Level  
Name: Zacchaeus Bolaji <contact>
Classes: 13 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 302016 in Nigeria Nigeria
Week rank: 246 8 in Nigeria Nigeria
Innovation award
Innovation award
Nominee: 8x


DB BackUp and Restore Class

Issues and pull requests welcome.

A PHP Class that helps take backup of DB as well as restore from backup.

Table of Contents


You will need PHP 7.x and composer.

Install using composer: composer require djunehor/db-backup-restore


use \Djunehor\DB\BackUp;

	 * @param string $host
	 * @param string $username
	 * @param string $password
	 * @param string $database
	 * @param string $charset
	 * @param string $lang
$db = new BackUp( 'localhost', 'root', '', 'test', 'utf8', 'en' );

// To backup DB
$db->backup ();

//To restore from backup
$db->restore ( __DIR__.'/backup/20121027194215_all_v1.sql')


Adapted from the class created by yanue


Check out the issues on GitHub and/or make a pull request to contribute!

File Role Description
.circleci (1 file)
build (1 file)
src (1 file, 1 directory)
.editorconfig Data Auxiliary data
.scrutinizer.yml Data Auxiliary data
.styleci.yml Data Auxiliary data
.travis.yml Data Auxiliary data Data Auxiliary data Data Auxiliary data
composer.json Data Auxiliary data Data Auxiliary data Data Auxiliary data Lic. License text
phpcs.xml.dist Data Auxiliary data
phpunit.xml.dist Data Auxiliary data Data Auxiliary data Doc. Documentation

  Files  /  .circleci  
File Role Description
   config.yml Data Auxiliary data

  Files  /  build  
File Role Description
   report.junit.xml Data Auxiliary data

  Files  /  src  
File Role Description
lang (1 directory)
   BackUp.php Class Class source

  Files  /  src  /  lang  
File Role Description
en (1 file)

  Files  /  src  /  lang  /  en  
File Role Description
   messages.php Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,632
This week:247

For more information send a message to info at phpclasses dot org.