This is a PHP 5 CLS/web script to backup a MySQL database.
It will create database dumps like mysqldump would create them but it is entirely written in PHP. This script will operate without command line access so it can be used in a shared hosting environment where access to mysqldump is not available.
I use this script to create regular backups with a cronjob but it can also offer the file as a download.
Ensure that you setup .htaccess protection before putting this into your docroot!
Features:
Example output:
Usage:
config options start at line 46. You need to at least set your MySQL info on lines 46-49. The rest of the settings should work fine.
Tested with:
ARCH Linux, CentOS 6, Windows 7 + 2008 running XAMPP
Downloads:
* first release.
mysql_backup-2012-03-30-1152-rev21.7z
It will create database dumps like mysqldump would create them but it is entirely written in PHP. This script will operate without command line access so it can be used in a shared hosting environment where access to mysqldump is not available.
I use this script to create regular backups with a cronjob but it can also offer the file as a download.
Ensure that you setup .htaccess protection before putting this into your docroot!
Features:
- create .sql dumps or compress the files with zip
- supports locking of the entire database or single tables before dumping data
- supports file download (note: this version does not provide access control)
- supports extended inserts
- detects and disables table keys during data insert
- detect views and create SQL commands to recreate them
Example output:
-- -- Table structure for table `workorder_notes_public` -- CREATE TABLE `workorder_notes_public`( `id` int(10) unsigned NOT NULL auto_increment, `note_id` int(10) unsigned NOT NULL, `public_string_id` varchar(255) NOT NULL, `access_counter` int(11) NOT NULL DEFAULT '0', `public_since` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM COLLATE utf8_general_ci AUTO_INCREMENT=2; LOCK TABLES workorder_notes_public WRITE; ALTER TABLE workorder_notes_public DISABLE KEYS -- -- Dumping data for table `workorder_notes_public` -- This table contains 1 entries -- INSERT INTO `workorder_notes_public`(`id`,`note_id`,`public_string_id`,`access_counter`,`public_since`) VALUES (1,1,'ydv8o444qr',0,'2012-03-30 13:06:53'); ALTER TABLE workorder_notes_public ENABLE KEYS UNLOCK TABLES workorder_notes_public; -- -- Rebuilding Index for table `workorder_notes_public` -- ALTER TABLE `workorder_notes_public` ADD UNIQUE `public_string_id`(`public_string_id`);
Usage:
config options start at line 46. You need to at least set your MySQL info on lines 46-49. The rest of the settings should work fine.
Tested with:
ARCH Linux, CentOS 6, Windows 7 + 2008 running XAMPP
Downloads:
* first release.
mysql_backup-2012-03-30-1152-rev21.7z
Add your comment