# Description

Congratulations !\
You are now the proud owner of the YaK PostgreSQL component type.\
Here is what it brings you:

## Sub-component types

The YaK supports two kinds of deployment of your PostgreSQL component type:

<details>

<summary>Standalone</summary>

Use this sub-component type to perform a single instance deployment of PostgreSQL.

</details>

<details>

<summary>HA (for High Availability)</summary>

Use this sub-component type to perform a multi-instances deployment of PostgreSQL, using:

* Patroni
* etcd
* Keepalived
* Load Balancer service
  * HAProxy (for on-premises deployment)
  * AWS Elastic Load Balancer (for deployment on AWS)
  * Azure Load Balancer (for deployment on Azure)
  * (More cloud Load Balancer services to come)

</details>

## Backup

The deployment of a PostgreSQL component with the YaK automatically configures two kinds of backups of the PostgreSQL instance:

<details>

<summary>Physical backup</summary>

Using pgBackRest (whole instance) and providing point-in-time recovery (PITR) capabilities.

</details>

<details>

<summary>Logical backup</summary>

Using pg\_dump (all databases of the instance).

</details>

Following backup jobs are automatically configured into the crontab of the `postgresql` OS user:

```sh
postgres@srv-pg-01:/home/postgres/ [PG01] crontab -l
#Ansible: PG01 - dmk-pg-dump - Daily dump of all databases
0 19 * * * /u01/app/postgres/local/dmk/bin/dmk-pg-dump.sh -s PG01 -f -r 7 -t /u90/pgdata/dumps
#Ansible: PG01 - pgBackRest - Weekly full backup
0 22 * * 0 /u01/app/postgres/product/pgbackrest-2.53/bin/pgbackrest --stanza=PG01 --log-level-console=info backup --type=full --checksum-page=n
#Ansible: PG01 - pgBackRest - Daily differential backup
0 22 * * 1-6 /u01/app/postgres/product/pgbackrest-2.53/bin/pgbackrest --stanza=PG01 --log-level-console=info backup --type=diff --checksum-page=n
```

{% hint style="info" %}
Pre-deployment customization of backup schedules will be available in a future release.
{% endhint %}

## Post-deploy custom Ansible roles

Although YaK deploys PostgreSQL instances in a standardized way and using dbi services' best practices, you can still customize your deployments by requesting the YaK to automatically deploy your own Ansible roles once the PostgreSQL instances are installed.

Use cases for this functionality could be:

* Automatic agent installation and configuration of your monitoring or backup tool
* Automatic scripts execution
* Automatic OS users creation
* And so on... depending your needs and your imagination

To benefit of this feature, you simply need to copy your own Ansible roles into the directory `/postgresql_instance/roles/custom_roles/` of the PostgreSQL component type archive (zip file).

{% hint style="info" %}
A more convenient way of storing your roles outside of the component type archive will be proposed in a future release.
{% endhint %}

{% hint style="danger" %} <mark style="color:red;">**DISCLAIMER**</mark>\
You are responsible of your custom Ansible roles and their behavior.

If your PostgreSQL instances no longer work correctly and as expected by YaK following the execution of your own Ansible roles, dbi services cannot be held responsible and the resulting issues cannot be covered by YaK support.
{% endhint %}
