Metadata-Version: 2.4
Name: testgres_pg_probackup2
Version: 0.10.0
Summary: Plugin for testgres that manages pg_probackup2
Author-email: Postgres Professional <testgres@postgrespro.ru>
License: PostgreSQL
Project-URL: HomePage, https://github.com/postgrespro/testgres-pg_probackup2
Keywords: pg_probackup,testing,testgres
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.7.3
Description-Content-Type: text/markdown
Requires-Dist: lz4
Requires-Dist: pefile
Requires-Dist: testgres<1.18,>=1.14.4
Requires-Dist: zstd

[![PyPI package version](https://badge.fury.io/py/testgres-pg_probackup2.svg)](https://badge.fury.io/py/testgres-pg_probackup2)

# testgres-pg_probackup2

Control and testing utility for [pg_probackup2](https://github.com/postgrespro/pg_probackup). Python 3.7+ is supported.


## Installation

To install `testgres-pg_probackup`, run:

```
pip install testgres-pg_probackup
```

We encourage you to use `virtualenv` for your testing environment.
The package requires testgres.

## Usage

### Environment variables

| Variable | Required | Default value | Description |
| - | - | - | - |
| PGPROBACKUP_TMP_DIR | No | tests/tmp_dirs | The root of the temporary directory hierarchy where tests store data and logs. Relative paths start from the current working directory. |
| PG_PROBACKUP_TEST_BACKUP_DIR_PREFIX | No | Temporary test hierarchy | Prefix of the test backup directories. Must be an absolute path. Use this variable to store test backups in a location other than the temporary test hierarchy. |
| PG_PROBACKUP_VALGRIND | No | Not set | Run pg_probackup through valgrind if the variable is set to 'y'. Setting  PG_PROBACKUP_VALGRIND_SUP (see below) to any value enables valgrind just like setting `PG_PROBACKUP_VALGRIND=y` would do. |
| PG_PROBACKUP_VALGRIND_SUP | No | Not set | Specify the path to a valgrind suppression file. If the variable is not set then a file named "valgrind.supp" is searched for in the current working directory (normally the root of pg_probackup repository). Setting  PG_PROBACKUP_VALGRIND_SUP to any value enables valgrind just like setting `PG_PROBACKUP_VALGRIND=y` (see above) would do. |

See [Testgres](https://github.com/postgrespro/testgres/tree/master#environment) on how to configure a custom Postgres installation using `PG_CONFIG` and `PG_BIN` environment variables.

### Examples

Here is an example of what you can do with `testgres-pg_probackup2`:

```python
# You can see full script here plugins/pg_probackup2/pg_probackup2/tests/basic_test.py
def test_full_backup(self):
    # Setting up a simple test node
    node = self.pg_node.make_simple('node', pg_options={"fsync": "off", "synchronous_commit": "off"})

    # Initialize and configure Probackup
    self.pb.init()
    self.pb.add_instance('node', node)
    self.pb.set_archiving('node', node)

    # Start the node and initialize pgbench
    node.slow_start()
    node.pgbench_init(scale=100, no_vacuum=True)

    # Perform backup and validation
    backup_id = self.pb.backup_node('node', node)
    out = self.pb.validate('node', backup_id)

    # Check if the backup is valid
    self.assertIn(f"INFO: Backup {backup_id} is valid", out)
```

## Authors

[Postgres Professional](https://postgrespro.ru/about)
