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.

