Saturday, February 20, 2010

Database synchronization using TableSyncer

Prerequisites:
ruby
ruby-devel
ruby-mysql
rubygems
libmysqlclient
libmysqlclient-devel
libopenssl-devel
zlib-devel

Installation:
sudo gem install mysql
sudo gem install table_syncer

Settings:
cd /usr/lib64/ruby/gems/1.8/gems/table_syncer-0.3.1/lib
cp table_syncer.rb table_syncer.rb.orig
vi table_syncer.rb

Add and change these lines:
local_source_db = {:host => '127.0.0.1', :user => 'user', :password => 'password', :db => 'SourceDatabase'}
local_test_db = {:host => '127.0.0.1', :user => 'user', :password => 'password', :db => 'test'}

Executing
table_syncer --from=local_source_db --to=local_test_db --tables=account

Reference:
http://code.google.com/p/ruby-roger-useful-functions/wiki/TableSyncer
http://www.freelinuxtutorials.com/quick-tips-and-tricks/sync-mysql-tables-via-ruby-gem-tablesyncer/
http://forums.mysql.com/read.php?116,178217,198518#msg-198518

No comments: