This is a plugin for the RedBeanPHP ORM, which will create Backup files for a MySql DB Server. This module explicitly only supports MySql and will throw an Exception if used with another DSN.
The backup file is created by using RedBeans connected DSN information along-side queries against the database to get the schema and values.
!IMPORTANT! This module will only export tables and nothing else. If you need something more sophisticated I'd recommend using the mysqldump script provided by MySql itself. The idea of this script is to quickly get a backups of the structure+data solely. So to make it clear:
This plugin will not export:
- Stored Procedures
really only Tables :)
!PRODUCTION USE NOTICE! I'm not going to garantuee for anything, so please don't rely 100% on this code before testing it on your own Database. At least for me it works :)
- PHP >= 5.3
- Mysql >= whatever version
- RedBean >= 3.5 (there is a dependency on the Dynamic Plugin R::ext() method)
Usage is quite simply since the use of R::ext() in RedBean 3.5.
- Create the folder where you'd like to have the backup-files created in manually.
- Set permissions on folder to allow php to create files in it
- Execute your desired way of backup-creation (see code below)
// create backup-file with auto name into folder backup R::performMysqlBackup("backup"); // create custom named backup-file into folder backup R::performMysqlBackup("backup", "MyFullBackup.sql");
Take a look at the included example.php. The RedBean verion in this repo is the all-in-one build 3.5