# Postgres Operator - Startup SQL and disable backup

**URL:** <https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306>\
**Category:** Percona Operator for PostgreSQL\
**Created:** [August 8, 2023, 12:02pm UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306 "2023-08-08T12:02:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mitre\_Angjelkoski](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mitre_angjelkoski/32/12149_2.png) [@Mitre\_Angjelkoski](https://forums.percona.com/u/Mitre_Angjelkoski)\
**Post date:** [August 8, 2023, 12:02pm UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/1 "2023-08-08T12:02:03Z")

</div>

I can’t find in the docs where I can asing a startup sql to the databases, which we do some operations to prepare the cluster and install extensions (postgis)  
Also because the use case is for seeded databases, backup is not needed and I would prefer it disabled but I can’t see that it’s possible.

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [August 8, 2023, 9:54pm UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/2 "2023-08-08T21:54:34Z")

</div>

Hello,

I apologize but I don’t quite understand what it is that you’ve written and am hoping you can reiterate your question.

Have I understood that you want to install the postgis extension into the datacluster(s)?

thank you.

---

<div class="post-metadata">

**Author:** ![Mitre\_Angjelkoski](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mitre_angjelkoski/32/12149_2.png) [@Mitre\_Angjelkoski](https://forums.percona.com/u/Mitre_Angjelkoski)\
**Post date:** [August 9, 2023, 9:22am UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/3 "2023-08-09T09:22:22Z")

</div>

Hello,

Apologies for being unclear.  
I’ve already found the InitSQL script but that doesnt work and I will probably fix it somehow.

Issues are:

1. I need to install postgis extension on the cluster
2. Need to disable backups altogether because I don’t need them for the certain instances.

I hope i made it clearer

Thanks.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [August 9, 2023, 4:16pm UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/4 "2023-08-09T16:16:39Z")

</div>

In the cr.yaml file, simply comment the entire ‘backup::schedule’ block to disable automatic backups.

---

<div class="post-metadata">

**Author:** ![Mitre\_Angjelkoski](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mitre_angjelkoski/32/12149_2.png) [@Mitre\_Angjelkoski](https://forums.percona.com/u/Mitre_Angjelkoski)\
**Post date:** [August 11, 2023, 7:07am UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/5 "2023-08-11T07:07:35Z")

</div>

Thank you, that worked. Would it be possible to have  
spec.backup.enabled boolean in some future release? It would be pretty handy.

Also is there any way I can debug the InitSQL script? I’ve set a configmap but nothing gets applied, probably doing something wrong

Thanks

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [August 14, 2023, 8:01am UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/6 "2023-08-14T08:01:32Z")

</div>

@Mitre_Angjelkoski init script logs can be found in the operators Pod logs. Do smth like:

```auto
kubectl logs --tail=2000 percona-postgresql-operator-6f96ffd8d4-82m2r

```

Search for (successful entry). Just search for `init SQL`:

```auto
time="2023-08-10T13:56:02Z" level=debug msg="applied init SQL" PostgresCluster=default/demo-cluster controller=postgrescluster controllerGroup=postgres-operator.crunchydata.com controllerKind=PostgresCluster key=init.sql name=demo-cluster-init namespace=default reconcileID=fcbe3798-2327-404b-8379-beb12826c102 stderr= stdout="You are now connected to database \"demo-db\" as user \"postgres\".\nCREATE SCHEMA\nCREATE TABLE\nCREATE TABLE\n" version=

```

**UPD:**  
this is how the error would look like:

```auto
time="2023-08-14T09:37:37Z" level=debug msg="applied init SQL" PostgresCluster=default/demo-cluster controller=postgrescluster controllerGroup=postgres-operator.crunchydata.com controllerKind=PostgresCluster key=init.sql name=demo-cluster-init namespace=default reconcileID=1d0cfdcc-0464-459a-be6e-b25eb46ed2c9 stderr="psql:<stdin>:11: ERROR: syntax error at or near \"KEYS\"\nLINE 2: ID INT PRIMARY KEYS NOT NULL,\n ^\n" stdout="You are now connected to database \"demo-db\" as user \"postgres\".\nCREATE SCHEMA\nCREATE TABLE\n" version=

```

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [September 4, 2023, 9:21am UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/7 "2023-09-04T09:21:28Z")

</div>

I wrote a blog post about bootstrapping: [https://www.percona.com/blog/bootstrap-postgresql-on-kubernetes/](https://www.percona.com/blog/bootstrap-postgresql-on-kubernetes/)

---

<div class="post-metadata">

**Author:** ![Mitre\_Angjelkoski](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mitre_angjelkoski/32/12149_2.png) [@Mitre\_Angjelkoski](https://forums.percona.com/u/Mitre_Angjelkoski)\
**Post date:** [October 24, 2023, 12:36pm UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/8 "2023-10-24T12:36:43Z")

</div>

Thanks that was really helpful!  
Although still there is an issue with installing postgis. As the extension is not even available to manually install, which means we cant use it…  
Any ideas?

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [October 26, 2023, 7:55am UTC](https://forums.percona.com/t/postgres-operator-startup-sql-and-disable-backup/24306/9 "2023-10-26T07:55:38Z")

</div>

@Mitre_Angjelkoski we will have PostGIS support in the next release (November).

Also we are working on a feature that would allow users to use any custom extension of their choice. PoC should be also available in November.

As for now, the only workaround is to build your own image with PostGIS.
