cywongnorman / sbmd-backup-mysql

Free PHP script to backup and restore tables from MySQL database.

Home Page:http://coursesweb.net/php-mysql/simple-backup-mysql-database_s2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sbmd-backup-mysql

SBMD - Simple Backup MySQL Database

This is a free and open source PHP script to Backup MySQL Database. The script creates the backup of the MySQL tables in SQL format and saves it into a ZIP file on server. The SBMD script can also restore the MySQL tables in your database from the SQL backup stored in ZIP archive.
You can also Download, and Delete the ZIP archives with the SQL backup.

Features

- Simple and easy to use interface to Backup and Restore MySQL tables.
- Supports both PDO and MySQLi for accessing MySQL databases in PHP.
- You can select the MySQL tables which to backup.
- The backup of the MySQL tables it is saved into a ZIP archive on server.
- You can Restore, Download, and Delete the ZIP file with backup from server.
- The script can be easily translated and used in other languages, without affecting the code.
- Easily to integrate into a CMS or other PHP project to add the backup MySQL database functionality.

Requirements

- PHP 5.4+
- Modern Browser with JavaScript enabled (Mozilla-Firefox, Google-Chrome, Opera, Internet-Explorer 9+).

Installation

  1. Copy the script on your server (with all its content).
  2. Set CHMOD 0755 (or 0777) permissions to the "backup/" folder on your server (it is used to store the ZIP files with the SQL backup).
  3. Access the "sbmd/bkmysql.php" file in your browser, with the address from server; for example: http://localhost/sbmd/bkmysql.php
  4. Add your connection data (MySQL server, Username, Password, Database name) to connect to your MySQL database. Then you can backup MySQL tables, and restore, download or delete the backup.

Other Specifications

• If you want to save the ZIP files in other directory on your server, modify the value of the $dir variable in the "bkmysql.php" file (line 5).

• If you want to use the script in other language, translate the texts from the lang_en.json file and save it in other "lang_...json" file, with the indice of the language, for example for Chinese save the texts in the "lang_ch.json". The texts in the ".json" file must be stored in valid JSON format. Then, change the value of the $lang variable in the "bkmysql.php" file (line 4) with the same indice ($lang ='ch';).

Advanced Usage

- If you want to use the backupmysql class into a CMS or other PHP project, include the backupmysql.class.php file in your project.
- The object instance of the backupmysql class requires two arguments: the indice of the language (used for the "lang_...json" file; default "en"), and the directory name where the backup files are saved (default "backup/").
Example:
include 'backupmysql.class.php';
$obj = new backupmysql('en', 'backup/');
- Then you can use these methods:
  • setMysql($conn_data) - store connection data in the $mysql property. Receives array with: ['host'=>'mysql-server', 'user'=>'user-name', 'pass'=>'password', 'dbname'=>database-name].
  • getTables() - returns array with all the tables in database (database name stored in: mysql['dbname'] property).
  • getListTables() - returns array: ['f'=>'form', 'er'='error message']. The "f" key contains a form with checkboxes with the tables returned by the getTables() method.
  • getSqlBackup($tables) - returns a SQL string format with the backup of the tables from the $tables parameter (array with the tables name to backup).
  • saveBkZip($tables) - creates ZIP archive with the SQL backup returned by the getSqlBackup($tables) method, and saves the archive in the directory from the $dir property. Receives array with the tables name to backup.
  • getListZip() - returns form with radio-buttons with all the ZIP archives stored in the folder added the $dir property.
  • restore($zp) - restores the backup tables. The $zp argument contains the name of the ZIP archive with the SQL file (stored in the folder added in the $dir property).
  • getZipFile($zip) - returns the ZIP file for download, from the folder added in $dir property. Receives the name of the ".zip" file.
  • delFile($file) - deletes the $file from the folder added in $dir property.
- By default, the backupmysql class uses MySQLi to connect to database. If the MySQLi extension is not available, the class will try to use PDO. If you want to make the default mode to PDO, set the "pdo" value to the $conn_mod property, in the backupmysql.class.php file (line 114).

• Home Page: http://coursesweb.net/php-mysql/simple-backup-mysql-database_s2

- This script is Free, and Open Source. You can use, modify and publish it freely.

About

Free PHP script to backup and restore tables from MySQL database.

http://coursesweb.net/php-mysql/simple-backup-mysql-database_s2

License:GNU General Public License v2.0


Languages

Language:PHP 100.0%