The project is in a healthy, maintained state
A tool to replicate MySQL data with the ability to mask sensitive information using Maxwell's Daemon
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 13.0
~> 3.0
~> 1.21

Runtime

~> 0.5.5
~> 1.3
 Project Readme

GammaReplication

GammaReplication is a tool that reads MySQL binlog using Maxwell's Daemon and replicates data to another MySQL database while masking sensitive information.

Features

  • Real-time replication using MySQL binlog
  • Column-level data masking
  • Flexible hook system for custom data transformation
  • Dry-run mode for operation verification

Requirements

  • Ruby 3.0.0 or higher
  • MySQL 5.7 or higher
  • Maxwell's Daemon
  • Java 8 or higher (for Maxwell's Daemon)

Directory Structure

The tool expects Maxwell's Daemon to be available in the same directory:

your_project/
├── maxwell/
│   └── bin/
│       └── maxwell
└── your_application_files

Installation

gem install gamma_replication

Or add this line to your application's Gemfile:

gem 'gamma_replication'

Setup

  1. Set up Maxwell's Daemon:
# Download Maxwell's Daemon
wget https://github.com/zendesk/maxwell/releases/download/v1.42.2/maxwell-1.42.2.tar.gz
tar xvf maxwell-1.42.2.tar.gz
mv maxwell-1.42.2 maxwell

# The maxwell executable will be available at maxwell/bin/maxwell
  1. Create configuration files:
bin/setup

This command will create the following files:

  • config.properties: Maxwell configuration
  • settings.yml: Database connection settings
  • data.yml: Table and masking configuration
  • hooks/: Masking scripts
  1. Configure MySQL:

    • Enable binlog in your MySQL configuration:
    [mysqld]
    server-id=1
    log-bin=master
    binlog_format=row
    • Create a user with replication privileges:
    CREATE USER 'maxwell'@'%' IDENTIFIED BY 'maxwell';
    GRANT ALL ON maxwell.* TO 'maxwell'@'%';
    GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'%';
  2. Edit configuration files:

settings.yml

in_database_config:
  host: localhost
  port: 3306
  username: repl_user
  password: password
  database: source_db

out_database_config:
  host: localhost
  port: 3306
  username: root
  password: password
  database: target_db

data.yml

- data:
    table: "users"
    hooks:
      - column:
          name:
            - "email"
          scripts:
            - "hooks/mask_email.rb"
      - column:
          name:
            - "phone_number"
          scripts:
            - "hooks/mask_phone_number.rb"

Usage

Start Replication

gamma_replication start -s settings.yml -d data.yml -m config.properties

Dry Run (Check SQL)

gamma_replication dryrun -s settings.yml -d data.yml -m config.properties

Custom Masking

Create Ruby scripts in the hooks/ directory to implement custom masking logic:

class MaskEmail
  def execute(apply, column, value)
    return value unless apply
    "masked_#{value}"
  end
end

Development

  1. Clone the repository
  2. Run bin/setup to install dependencies
  3. Run rake spec to run the tests
  4. Run bin/console for an interactive prompt

License

The gem is available as open source under the terms of the MIT License.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request