Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

MySQL::Backup
Perl extension for making backups of mysql DBs.

MySQL::Backup - Perl extension for making backups of mysql DBs.


SYNOPSIS


  use MySQL::Backup;

  my $mb = new MySQL::Backup('database','127.0.0.1','user','password',{'USE_REPLACE' => 1, 'SHOW_TABLE_NAMES' => 1});

  print $mb->create_structure();

  print $mb->data_backup();


DESCRIPTION

MySQL::Backup should be useful for people, who needed in backuping mysql DBs by perl script and doesn't want to use mysqldump or doesn't able to do this.

Main Methods

  • $mb->create_structure() - returns structure of current database

  • $mb->data_backup() returns a full DATA backup of current database

  • $mb->table_data($tablename) - get all data from the table with $tablename

  • $mb->table_desc($tablename) - get a structure of inputed table

  • $mb->new_from_DBH($dbh) - if you have already DBI connection, you can use this

  • $mb->run_restore_script($filename) - Just DROPs all from current DB and run all sql from the specified file (param is filepath to needed file)

  • $mb->run_upgrade_script($filename) - opens file by set filepath, then analyzes differencies in proposed and current structures and tries to fix differencies in DB. For instance: you have 1 table in DB with 3 columns, and one string CREATE TABLE ... with same name in the file, but CREATE TABLE describes 4 columns,.. after running this you should have 4 columns in table in DB. Also, all INSERTs/REPLACEs from file will be executed(also, please be careful on execute stage all INSERTs will be changed to REPLACE)

Params

Params could be set on creating, like shown in example, or/and set/changed as you should see below:

  • $mb->{'param'}->{'USE_REPLACE'} - '1' means using REPLACE instead of INSERT

  • $mb->{'param'}->{'SHOW_TABLE_NAMES'} - '1' means outputing a string in data_backup that marks actions on which table should be done

  • $mb->{'param'}->{'tables'} - this param is a link to array with table names,.. can be used if you're needed to backup only few tables from DB (used by create_structure/data_backup)


SEE ALSO

DBI, DBD::mysql and http://dev.mysql.com


AUTHOR

Dmitry Nikolayev <dmitry@cpan.org>, http://perl.dp.ua/resume.html


THANKS

Thanks for DotHost Hosting Provider: http://dothost.ru for their Tech. support.

Also, Thanks to Dree <dree@perl.it> for his comments and suggestions.


COPYRIGHT AND LICENSE

Copyright (C) 2006 by Dmitry Nikolayev

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy