PHPMyExport
|
Size: 520
Comment:
|
Size: 7656
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| ##(see the SpecSpec for an explanation) ## Register at https://launchpad.net/distros/ubuntu/+specs |
||<tablestyle="float:right; font-size: 0.9em; background:#F1F1ED;margin: 0 0 1em 1em;" style="padding:2.0em;">'''Contents'''[[BR]][[TableOfContents]]|| |
| Line 5: | Line 4: |
| * '''Created''': [[Date(2007-10-18T11:13:19Z)]] by AndersWallenquist * '''Contributors''': Axel == Summary == == Rationale == == Use cases == == Scope == == Design == == Implementation == === Code === === Data preservation and migration === == Unresolved issues == == BoF agenda and discussion == |
* '''Source code''': https://code.launchpad.net/phpmyexport/ * '''Bugtracker''': https://bugs.launchpad.net/phpmyexport/ * '''Created''': [[Date(2007-10-18T11:13:19Z)]] by Axel <[email protected]> * '''Contributors''': Axel <[email protected]> = Summary = PHPMyExport is a PHP written script. It allows webmasters, administrators and any database users to dump and store the databases. PHPMyExport is an easy, fast and powerful PHP class, which allows multiple databases dump. This tool is to replace the mysqldump tool, unavailable for hosted websites, not user-friendly or just too complicated to use. It provides a web based interface, for an easy going backup and security system. PHPMyExport is embeded with ADODB, it supports many many database types: mysql, mysqli, postgresql, sqllte, mssql, access, ... PHPMyExport can list the databases and the tables of a given host. It allows you to choose very precisely what database/table you wanna backup. PHPMyExport supports many dump methods: you can either display the dump, append it into in file, force the download of the file or reinject directly the dump in another host/database/table. = Requirements = PHPMyExport new version is written in PHP5. Therefore it requires: * A Web server: can be [http://httpd.apache.org Apache], IIS, ... * PHP5 language [http://www.php.net php.net] * Any of the '''ADODB''' supported databases types = Installation = == Using sources == At first, check the requirements. If everything is OK, download the source archive. Uncompress it into a Web accessible directory (/var/www/phpmyexport for instance). You're done :-) == Using Bazaar sources == You may checkout the source repository in order to always be up to date. To checkout, run: cd /path/to/your/directory bzr checkout http://bazaar.launchpad.net/~a-vi/phpmyexport/trunk __Caution__: the trunk is the development directory. Code may be unstable. Trunk is mostly used for testing purposes. = The PHPMyExport engine = == Instantiate the class == At first, when you need the PHPMyExport engine, you need to include the class: {{{ include 'phpmyexport.class.php'; }}} ... and to instantiate it. PHPMyExport expects at least one parameter: the DNS string (check [http://phplens.com/lens/adodb/docs-adodb.htm ADODB Documentation] for details): {{{ $app = new PHPMyExport('mysql://root:@localhost'); }}} If you want to run in debug mode (error messages will be printed out), do: {{{ $app = new PHPMyExport('mysql://root:@localhost', true); }}} == Setting Options == Here is the list of the options you may set: {{{ 'export_structure' => true, 'export_datas' => true, 'query_type' => array('insert', 'replace'), 'use_transaction' => false, 'add_create_database' => true, 'add_drop_database' => true, 'add_drop_table' => true, }}} === export_structure === * true (''default''): will add queries to create databases and tables * false: will not create databases or tables === export_datas === * true (''default''): tables content will also be dumped * false: does not dump tables content === query_type === * insert (''default''): will output INSERT INTO queries * replace: will output REPLACE INTO queries === use_transaction === * true: transactions will be used. It depends on the database engine. Transaction is rollbacked when an error occurs * false (''default''): no transaction is used === add_create_database === * true (''default''): add the CREATE DATABASE query for each database you dump * false: does not create databases === add_drop_database === * true (''default''): add the DROP DATABASE IF EXISTS query for each database you dump * false: does not drop existing databases === add_drop_table === * true (''default''): add the DROP TABLE IF EXISTS query for each table you dump * false: does not drop existing tables === more to come... === You've got ideas, questions? You wanna contribute? See here: https://launchpad.net/phpmyexport To set an option, do: {{{ $app->setOption('<option_name>', '<option_value>'); }}} For example: {{{ $app->setOption('add_drop_database', false); }}} == Setting dump method == PHPMyExport offers you 4 ways to export your dump: === output === If you choose this option, the dump will be printed out in your browser (or client). That can be convenient for small and medium dumps. Be careful with big and massive dump: browsers are not keen to display thousands and thousands of lines. {{{ $app->setDumpMethod('output')); }}} === download === PHPMyExport will trigger a download box. You will be able to save the dump on your local machine. The option accepts one optional parameter: * filename (''optional''): the dump filename {{{ $app->setDumpMethod('download', array('filename'=>'dump.sql')); }}} === write === PHPMyExport will open a file on the server hard drive and append the dump into it. The option accepts two parameters: * path (''mandatory''): the path the file will be saved in. Make sure PHP has write access in this directory * filename (''optional''): the file name {{{ $app->setDumpMethod('write', array('path'=>'/home/axel', 'filename'=>'dump.sql')); }}} === inject === PHPMyExport can now open a new database connection to append the dump. The options accepts one mandatory argument: * DNS driver (check [http://phplens.com/lens/adodb/docs-adodb.htm ADODB Documentation] for details): <driver>://<username>:<password>@<hostname>/<database> == Choose the databases and the tables to dump == PHPMyExport can list for you the databases and the tables of the current connection. To get the databases list, just do: {{{ $databases = $app->getDatabasesList(); }}} To get the tables list for a given database, just do: {{{ $table = $app->getTablesList('<database>'); }}} Now you have to build the databases and tables list you wanna dump. You may use the '''*''' wildcard meaning: ''everything''. You may choose all databases and all tables or choose one database and all its tables or choose just a couple of tables. You can actually do whatever you want. Here is an example: {{{ $todump = array( 'mysql'=> array('user', 'db'), 'information_schema'=>'*' ); }}} In the example, you're going to backup: * two tables from the ''mysql'' database: ''user'' and ''db'' * all tables from the ''information_shema'' database You can also do : {{{ $todump = array('*'); }}} You're going to backup all databases. == Start the dump == Now you're done with the options. You probably want to start the dump now :-) Just use the goDumpNow() function. This function requires one argument: the list of databases and tables you've generated above. The result is: {{{ $app->goDumpNow($todump); }}} = Notes = PHPMyExport is still under heavy development. This a beta version. For now, only the engine is being released. Unlike the previous versions, there is no graphical interface (GUI) for this version. Once the engine is ready, that will be my next task. Actually, anyone could contribute and help at developing and designing a GUI for PHPMyExport. This page also needs modifications. This is the very first version, and I probably forgot a couple of things ;-). |
| Line 30: | Line 222: |
| CategorySpec | CategorySpec CategoryDocumentation |
ContentsBRTableOfContents |
Launchpad entry: https://launchpad.net/phpmyexport/
Source code: https://code.launchpad.net/phpmyexport/
Bugtracker: https://bugs.launchpad.net/phpmyexport/
Created: Date(2007-10-18T11:13:19Z) by Axel <[email protected]>
Contributors: Axel <[email protected]>
1. Summary
PHPMyExport is a PHP written script. It allows webmasters, administrators and any database users to dump and store the databases.
PHPMyExport is an easy, fast and powerful PHP class, which allows multiple databases dump. This tool is to replace the mysqldump tool, unavailable for hosted websites, not user-friendly or just too complicated to use. It provides a web based interface, for an easy going backup and security system.
PHPMyExport is embeded with ADODB, it supports many many database types: mysql, mysqli, postgresql, sqllte, mssql, access, ... PHPMyExport can list the databases and the tables of a given host. It allows you to choose very precisely what database/table you wanna backup. PHPMyExport supports many dump methods: you can either display the dump, append it into in file, force the download of the file or reinject directly the dump in another host/database/table.
2. Requirements
PHPMyExport new version is written in PHP5. Therefore it requires:
A Web server: can be [http://httpd.apache.org Apache], IIS, ...
PHP5 language [http://www.php.net php.net]
Any of the ADODB supported databases types
3. Installation
3.1. Using sources
At first, check the requirements. If everything is OK, download the source archive. Uncompress it into a Web accessible directory (/var/www/phpmyexport for instance). You're done
3.2. Using Bazaar sources
You may checkout the source repository in order to always be up to date. To checkout, run: cd /path/to/your/directory bzr checkout http://bazaar.launchpad.net/~a-vi/phpmyexport/trunk
Caution: the trunk is the development directory. Code may be unstable. Trunk is mostly used for testing purposes.
4. The PHPMyExport engine
4.1. Instantiate the class
At first, when you need the PHPMyExport engine, you need to include the class:
include 'phpmyexport.class.php';
... and to instantiate it. PHPMyExport expects at least one parameter: the DNS string (check [http://phplens.com/lens/adodb/docs-adodb.htm ADODB Documentation] for details):
$app = new PHPMyExport('mysql://root:@localhost');If you want to run in debug mode (error messages will be printed out), do:
$app = new PHPMyExport('mysql://root:@localhost', true);
4.2. Setting Options
Here is the list of the options you may set:
'export_structure' => true,
'export_datas' => true,
'query_type' => array('insert', 'replace'),
'use_transaction' => false,
'add_create_database' => true,
'add_drop_database' => true,
'add_drop_table' => true,
4.2.1. export_structure
true (default): will add queries to create databases and tables
- false: will not create databases or tables
4.2.2. export_datas
true (default): tables content will also be dumped
- false: does not dump tables content
4.2.3. query_type
insert (default): will output INSERT INTO queries
- replace: will output REPLACE INTO queries
4.2.4. use_transaction
- true: transactions will be used. It depends on the database engine. Transaction is rollbacked when an error occurs
false (default): no transaction is used
4.2.5. add_create_database
true (default): add the CREATE DATABASE query for each database you dump
- false: does not create databases
4.2.6. add_drop_database
true (default): add the DROP DATABASE IF EXISTS query for each database you dump
- false: does not drop existing databases
4.2.7. add_drop_table
true (default): add the DROP TABLE IF EXISTS query for each table you dump
- false: does not drop existing tables
4.2.8. more to come...
You've got ideas, questions? You wanna contribute? See here: https://launchpad.net/phpmyexport
To set an option, do:
$app->setOption('<option_name>', '<option_value>');For example:
$app->setOption('add_drop_database', false);
4.3. Setting dump method
PHPMyExport offers you 4 ways to export your dump:
4.3.1. output
If you choose this option, the dump will be printed out in your browser (or client). That can be convenient for small and medium dumps. Be careful with big and massive dump: browsers are not keen to display thousands and thousands of lines.
$app->setDumpMethod('output'));
4.3.2. download
PHPMyExport will trigger a download box. You will be able to save the dump on your local machine. The option accepts one optional parameter:
filename (optional): the dump filename
$app->setDumpMethod('download', array('filename'=>'dump.sql'));
4.3.3. write
PHPMyExport will open a file on the server hard drive and append the dump into it. The option accepts two parameters:
path (mandatory): the path the file will be saved in. Make sure PHP has write access in this directory
filename (optional): the file name
$app->setDumpMethod('write', array('path'=>'/home/axel', 'filename'=>'dump.sql'));
4.3.4. inject
PHPMyExport can now open a new database connection to append the dump. The options accepts one mandatory argument:
DNS driver (check [http://phplens.com/lens/adodb/docs-adodb.htm ADODB Documentation] for details): <driver>://<username>:<password>@<hostname>/<database>
4.4. Choose the databases and the tables to dump
PHPMyExport can list for you the databases and the tables of the current connection.
To get the databases list, just do:
$databases = $app->getDatabasesList();
To get the tables list for a given database, just do:
$table = $app->getTablesList('<database>');Now you have to build the databases and tables list you wanna dump. You may use the * wildcard meaning: everything. You may choose all databases and all tables or choose one database and all its tables or choose just a couple of tables. You can actually do whatever you want. Here is an example:
$todump = array(
'mysql'=> array('user', 'db'),
'information_schema'=>'*'
);In the example, you're going to backup:
two tables from the mysql database: user and db
all tables from the information_shema database
You can also do :
$todump = array('*');You're going to backup all databases.
4.5. Start the dump
Now you're done with the options. You probably want to start the dump now
Just use the goDumpNow() function. This function requires one argument: the list of databases and tables you've generated above. The result is:
$app->goDumpNow($todump);
5. Notes
PHPMyExport is still under heavy development. This a beta version. For now, only the engine is being released. Unlike the previous versions, there is no graphical interface (GUI) for this version. Once the engine is ready, that will be my next task. Actually, anyone could contribute and help at developing and designing a GUI for PHPMyExport.
This page also needs modifications. This is the very first version, and I probably forgot a couple of things ;-).
PHPMyExport (last edited 2008-08-06 17:00:17 by localhost)