Development

Requirements

PGHoard can backup and restore PostgreSQL versions 9.3 and above, but is only tested and actively developed with version 10 and above.

The daemon is implemented in Python and is tested and developed with version 3.6 and above. The following Python modules are required:

The following Python modules are required:

  • psycopg2 to look up transaction log metadata

  • requests for the internal client-server architecture

Optional requirements include:

  • azure for Microsoft Azure object storage (patched version required, see link)

  • botocore for AWS S3 (or Ceph-S3) object storage

  • google-api-client for Google Cloud object storage

  • cryptography for backup encryption and decryption (version 0.8 or newer required)

  • snappy for Snappy compression and decompression

  • zstandard for Zstandard (zstd) compression and decompression

  • systemd for systemd integration

  • swiftclient for OpenStack Swift object storage

  • paramiko for sftp object storage

Developing and testing PGHoard also requires the following utilities: flake8, pylint and pytest.

PGHoard has been developed and tested on modern Linux x86-64 systems, but should work on other platforms that provide the required modules.

Vagrant

The Vagrantfile can be used to setup a vagrant development environment. The vagrant environment has python 3.7, 3.8, 3.9 and 3.10 virtual environments and installations of postgresql 10, 11 and 12, 13 and 14.

By default vagrant up will start a Virtualbox environment. The Vagrantfile will also work for libvirt, just prefix VAGRANT_DEFAULT_PROVIDER=libvirt to the vagrant up command.

Any combination of Python (3.7, 3.8, 3.9 and 3.10) and Postgresql (10, 11, 12, 13 and 14)

Bring up vagrant instance and connect via ssh:

vagrant up
vagrant ssh
vagrant@ubuntu2004:~$ cd /vagrant

Test with Python 3.7 and Postgresql 10:

vagrant@ubuntu2004:~$ source ~/venv3.7/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=10 make unittest
vagrant@ubuntu2004:~$ deactivate

Test with Python 3.8 and Postgresql 11:

vagrant@ubuntu2004:~$ source ~/venv3.8/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=11 make unittest
vagrant@ubuntu2004:~$ deactivate

Test with Python 3.9 and Postgresql 12:

vagrant@ubuntu2004:~$ source ~/venv3.9/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=12 make unittest
vagrant@ubuntu2004:~$ deactivate

Test with Python 3.10 and Postgresql 13:

vagrant@ubuntu2004:~$ source ~/venv3.10/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=13 make unittest
vagrant@ubuntu2004:~$ deactivate

And so on

Building

To build an installation package for your distribution, go to the root directory of a PGHoard Git checkout and run:

Debian:

make deb

This will produce a .deb package into the parent directory of the Git checkout.

Fedora:

make rpm

This will produce a .rpm package usually into rpm/RPMS/noarch/.

Python/Other:

python setup.py bdist_egg

This will produce an egg file into a dist directory within the same folder.