by hellofresh

hellofresh /klepto

Klepto is a tool for copying and anonymising data

144 Stars 20 Forks Last release: 4 months ago (v0.2.1) MIT License 410 Commits 12 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:



Build Status Go Report Card Go Doc

Klepto is a tool for copying and anonymising data

Klepto is a tool that copies and anonymises data from other sources.


Klepto helps you to keep the data in your environment as consistent as possible by copying it from another environment's database.

You can use Klepto to get production data but without sensitive customer information for your testing or local debugging.


  • Copy data to your local database or to stdout, stderr
  • Filter the source data
  • Anonymise the source data

Supported Databases

  • PostgreSQL
  • MySQL

If you need to get data from a database type that you don't see here, build it yourself and add it to this list. Contributions are welcomed :)


  • Active connection to the IT VPN
  • Latest version of pg_dump installed (Only required when working with PostgreSQL databases)


Klepto is written in Go with support for multiple platforms. Pre-built binaries are provided for the following:

  • macOS (Darwin) for x64, i386, and ARM architectures
  • Windows
  • Linux

You can download the binary for your platform of choice from the releases page.

Once downloaded, the binary can be run from anywhere. We recommend that you move it into your

for easy use, which is usually at


Klepto uses a configuration file called

to define your table structure. If your table is normalized, the structure can be detected automatically.

For dumping the last 10 created active users, your file will look like this:

  Name = "users"
    email = "EmailAddress"
    username = "FirstName"
    password = "SimplePassword"
    Match = "users.status = 'active'"
    Limit = 10
      created_at = "desc"

After you have created the file, run:


klepto steal \
--from="postgres://user:[email protected]/fromDB?sslmode=disable" \
--to="postgres://user:[email protected]/toDB?sslmode=disable" \


klepto steal \
--from="user:[email protected](localhost:3306)/fromDB?sslmode=disable" \
--to="user:[email protected](localhost:3306)/toDB?sslmode=disable" \

Behind the scenes Klepto will establishes the connection with the source and target databases with the given parameters passed, and will dump the tables.

Steal Options

The available options can be seen by running

klepto steal -h

Klepto Steal Help

We recommend to always set the following parameters: -

to alleviate the pressure over both the source and target databases. -
to limit the number of open connections, so that the source database does not get overloaded.

Configuration File Options

You can set a number of keys in the configuration file. Below is a list of all configuration options, followed by some examples of specific keys.

  • Matchers
    - Variables to store filter data. You can declare a filter once and reuse it among tables.
  • Tables
    - A Klepto table definition.
    • Name
      - The table name.
    • IgnoreData
      - A flag to indicate whether data should be imported or not. If set to true, it will dump the table structure without importing data.
    • Filter
      - A Klepto definition to filter results.
    • Match
      - A condition field to dump only certain amount data. The value may be either expression or correspond to an existing
    • Limit
      - The number of results to be fetched.
    • Sorts
      - Defines how the table is sorted.
    • Anonymise
      - Indicates which columns to anonymise.
    • Relationships
      - Represents a relationship between the table and referenced table.
    • Table
      - The table name.
    • ForeignKey
      - The table's foreign key.
    • ReferencedTable
      - The referenced table name.
    • ReferencedKey
      - The referenced table primary key.


You can dump the database structure without importing data by setting the

value to
 Name = "logs"
 IgnoreData = true


Matchers are variables to store filter data. You can declare a filter once and reuse it among tables: ```toml [[Matchers]] Latest100Users = "ORDER BY users.created_at DESC LIMIT 100"

[[Tables]] Name = "users" [Tables.Filter] Match = "Latest100Users"

[[Tables]] Name = "orders" [[Tables.Relationships]] ForeignKey = "user_id" ReferencedTable = "users" ReferencedKey = "id" [Tables.Filter] Match = "Latest100Users" ```

See examples for more.


You can anonymise specific columns in your table using the

key. Anonymisation is performed by running a Faker against the specified column.
  Name = "customers"
    email = "EmailAddress"
    firstName = "FirstName"

[[Tables]] Name = "users" [Tables.Anonymise] email = "EmailAddress" password = "literal:1234"

This would replace these 4 columns from the

tables and run
against them respectively. We can use
to specify a constant we want to write for a column. In this case,
password = "literal:1234"
would write
for every row in the password column of the users table.

Available data types for anonymisation

Available data types can be found in fake.go. This file is generated from https://github.com/icrowley/fake (it must be generated because it is written in such a way that Go cannot reflect upon it).

We generate the file with the following:

$ go get github.com/ungerik/pkgreflect
$ fake master pkgreflect -notypes -novars -norecurs vendor/github.com/icrowley/fake/



key represents a relationship between the table and referenced table.

To dump the latest 100 users with their orders: ```toml [[Tables]] Name = "users" [Tables.Filter] Limit = 100 [Tables.Filter.Sorts] created_at = "desc"

[[Tables]] Name = "orders" [[Tables.Relationships]] # behind the scenes klepto will create a inner join between orders and users ForeignKey = "userid" ReferencedTable = "users" ReferencedKey = "id" [Tables.Filter] Limit = 100 [Tables.Filter.Sorts] createdat = "desc" ```


Example configuration files for intfood and the ordering tool can be found on Klepto Examples on Confluence.


Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.


This project is licensed under the MIT License - see the LICENSE file for details

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.