pg_anon Open-Source Tool Receives Major Updates for PostgreSQL Data Masking and Partial Database Operations

Tantor Labs has released version 1.11.0 of pg_anon, an open-source utility designed to mask personal data in PostgreSQL databases while preserving structure and relationships. The update introduces packaging as a standard Python package, support for partial dumps and restores using whitelist and blacklist dictionaries, and improved handling of complex schema elements such as partitioned tables, generated columns, and custom types. Performance improvements include switching the dump engine to asyncio, single-query metadata collection, and on-the-fly gzip compression to reduce memory usage on large databases. New CLI options allow clean or drop operations on target databases, privilege ignoring, and passthrough of pg_dump and pg_restore flags. A REST API was added to enable integration into CI/CD pipelines and automated self-service systems for nightly masked database refreshes. The tool helps organizations comply with data protection requirements by creating pseudonymized copies suitable for development, testing, and contractor environments.

HabrTranslated from Russian

Read at source

pg_anon, an open-source tool developed by Tantor Labs for masking personal data in PostgreSQL, has received significant updates over the past year. The new version 1.11.0 introduces packaging as a standard Python package, support for partial database dumps and restores, enhanced handling of complex schemas, and a REST API for automation.

The tool addresses a common challenge in organizations that need to create copies of production databases for developers, analysts, or contractors without exposing real personal data. Direct copying of production databases risks violating internal security policies and data protection laws such as 152-FZ and GDPR. pg_anon performs masking by replacing field values with plausible alternatives while keeping table structures and referential integrity intact, resulting in a pseudonymized dataset.

Installation and New CLI Structure

Installation now uses standard pip commands with optional dependency groups. Users can install the base package or add support for the REST API and development tools. Two commands are provided after installation: pg_anon for core operations and pg_anon_api for running the REST service. Each operation mode is now a separate subcommand, improving usability compared to the previous single-entry-point approach.

Partial Dump and Restore Capabilities

A major addition is support for partial dumps and restores. Administrators can specify tables to include or exclude using dictionary files passed via command-line options. The tool automatically collects DDL for dependent objects such as custom types, domains, and functions to ensure successful restoration on a clean target database without manual pre-creation of supporting objects.

Performance and Schema Improvements

The dump engine was rewritten using asyncio instead of multiprocessing. Metadata collection now uses a single query instead of per-table connections, dramatically reducing preparation time on databases with thousands of tables. Compression was changed to a streaming model with lower gzip levels, eliminating memory leaks on large JSON-heavy tables. Support was added for partitioned tables, inherited tables, generated columns, identity sequences, and object names containing special characters.

REST API and Automation

The new REST API enables integration into automated pipelines. Standardized error codes, operation identifiers, custom headers, and log retrieval features support use in CI/CD systems that refresh masked database copies on a schedule without human intervention.

The release maintains backward compatibility with older command syntax while providing a more structured and extensible foundation for data masking workflows in regulated environments.

Meridian digestThe week's most consequential security stories, distilled into one briefing.See the digest

More in Privacy & Surveillance

Maximizing iPhone Privacy: Essential Settings to Enable, Disable, and Verify Immediately
Top 10 Secure DNS Servers for Privacy, Threat Blocking and Ad Filtering in 2026
WebRTC IP Leaks Explained: Why Disabling the Protocol Harms Anonymity in Anti-Detect Browsers