> For the complete documentation index, see [llms.txt](https://dbi-services.gitbook.io/yak-user-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dbi-services.gitbook.io/yak-user-doc/manage-components/component-types/postgresql/description.md).

# 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dbi-services.gitbook.io/yak-user-doc/manage-components/component-types/postgresql/description.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
