pg_anon stateless REST API service

This service is designed for integrating pg_anon into any system via HTTP queries. It acts as a wrapper for the CLI version of pg_anon. REST API calls prepare command line parameters and launch the CLI version of pg_anon.

The service does not maintain state and does not store data in a database, allowing it to be easily scaled without additional configuration. However, this means that the system integrating pg_anon must implement its own storage for dictionaries, dumps, and restores.

The service is not suitable for fully autonomous operation.

Warning

The DBMS shall be accessible from Platform server to function correctly.

Prerequisites

  1. This tool supports Python version 3.11 and above. The source code is hosted in the repository.

  2. All dumps will be saved in the directory /path_to_pg_anon/output. When scaling the REST API of the service, a symbolic link (symlink) for this directory shall be created on the shared disk. This is needed because restore operations also refer to dumps at /path_to_pg_anon/output.

Installation instructions

  1. Set up a virtual environment and install pg_anon dependencies:

    • Install Python3:

      • for Ubuntu

      sudo apt-get install python3.11
      
      • for Redhat/Centos:

      sudo yum install python311
      
    • Clone the repository:

      git clone https://github.com
      
    • Navigate to the project directory:

      cd pg_anon
      
    • Set up the virtual environment:

      • Set up the virtual environment:

      python3 -m venv venv
      
      • Activate the virtual environment:

      source venv/bin/activate
      
    • Install dependencies:

      pip install -r requirements.txt
      
  2. Navigate to the service directory:

    cd rest_api
    
  3. Install the REST API service dependencies:

    pip install -r requirements.txt
    

Configuration setup

To work with multiple versions of PostgreSQL, create the configuration file /path_to_pg_anon/config.yml according to the instructions This configuration file will be used automatically.

Usage

Start the service:

python -m uvicorn rest_api.api:app