Copy data between different databases with copydata script

Links: http://www.dbatools.net/mytools/perl-copy-data-scripts.html

    We start to introduce MySQL and PostgreSQL into our business system, as a replacement of Oracle, to save the license cost. First we need to move some data from Oracle to MySQL or PostgreSQL for performance testing or business testing. It's not easy work for a Linux & UNIX DBAs to support different types of database systems.

    Perl is very powerful script language for DBAs. I wrote the asyncdata script with Perl, it support different types of databases well, but asyncdata is not good for one time data copy, so we still need a script to copy static data from one database to another database, so I write a new script (copydata.pl) according the source code of asyncdata.

    The table structure of the source table and target table should be the same, the column name must be exactly matched, however the target table can have more columns than source table. But the table name can be different, just put the source table name and target table name into a configuration file.

SOURCE_TABLE1 # TARGET_TABLE1
SOURCE_TABLE2 # TARGET_TABLE3
......

    And them run the copydata script to copy the data, as following.

$ copydata.pl -s test#test#Oracle:test1 -t test#test#Oracle:test2 -c test.cfg
08/10 19:51:19 - Replication started, 2 tables in configuration file.
......

    Of cause, you need to insetall Perl and Perl DBI before you start to use it. Perl is my primary script language for database management tools now.

Post a comment

Remember Me?

« Previous | Main | Next »

Powered by
Movable Type 4.25