Build a masked QA database from a production sample, from the command line
QA needs data that looks like production: the same keys, cities, credit limits and signup dates. It does not need real names, tax IDs, e-mails or phone numbers. This is a lab example, and even the "production" side is generated: names from two short lists, a tax ID in the CPF layout built from the id (not a valid number), e-mails at example.com . No real data appears. It uses dbSlice by Thinwork…
Generating a masked QA database from a production sample requires the right tools and techniques. The key is to maintain key data points while obscuring sensitive information. In this lab scenario, dbSlice by Thinwork is used to create the masked version.
The job file specifies the mode as "ForceLoad", which first truncates the target table before reloading it with the masked data. This ensures the production data is never used directly.
The "where" clause limits the selection to every 17th row from the source, resulting in 588 rows out of the 10,000 total. This sampling provides a representative subset for the QA environment.
Column-level masking is applied via the "ofuscar" parameter. Each column has a specific transformation rule:
- Full name becomes a template with the key
- Tax ID is masked as a CPF format
- Email is replaced with a placeholder
- Phone number is shortened to the first 7 digits
- City and segment remain unchanged
- Credit limit and created_at are left original
Birth date is masked using the default rule for its date type (1900-01-01). Primary and foreign keys are preserved exactly.
With the masking configuration in place, dbSlice reads the sample data file, processes the 588 rows according to the rules, and writes the masked version to the target database. This operation completes in just 0.3 seconds.
The result is a QA database that mirrors the structure and key data of production, but with all sensitive information replaced. Running the mask again yields identical results, allowing repeatable refreshes as needed. While the email addresses and field lengths remain, the actual values are concealed.
This masking process protects real data while still providing a useful copy for QA testing, without needing to access the actual production system. For more details on the Linux implementation, job syntax, and additional masking rules, the full article provides the step-by-step Linux commands. The article also explains how to schedule these masks and introduces the four case studies in the series available on dbslice.net.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to