# How to grant execute on pg\_backup\_start

**URL:** <https://forum.ansible.com/t/how-to-grant-execute-on-pg-backup-start/6105>\
**Category:** Get Help\
**Tags:** postgresql\
**Created:** [May 31, 2024, 1:46pm UTC](https://forum.ansible.com/t/how-to-grant-execute-on-pg-backup-start/6105 "2024-05-31T13:46:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![svenna](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/svenna/32/3627_2.png) [@svenna](https://forum.ansible.com/u/svenna)\
**Post date:** [May 31, 2024, 1:46pm UTC](https://forum.ansible.com/t/how-to-grant-execute-on-pg-backup-start/6105/1 "2024-05-31T13:46:57Z")

</div>

i am trying to setup pgbackrest with ansible and i have stumbled upon GRANTing EXECUTE on the function pg\_backup\_start

i have the following ansible snippet:

```auto
  - name: GRANT EXECUTE on function pg_start_backup
    community.postgresql.postgresql_privs:
      database: postgres
      privs: EXECUTE
      schema: pg_catalog
      objs: "pg_start_backup(label text: fast boolean)"
      type: function
      roles: ${dockeruser}
      login_user: ${db_admin_user}
      login_password: ${db_admin_password}
      login_host: localhost

```

which gives the following error. which indicates that the function doesnt exist

```auto
│ "invocation": {
│ "module_args": {
│ "ca_cert": null,
│ "connect_params": {},
│ "database": "postgres",
│ "fail_on_role": true,
│ "grant_option": null,
│ "login_host": "localhost",
│ "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
│ "login_unix_socket": "",
│ "login_user": "postgres",
│ "objs": "pg_start_backup(label text: fast boolean)",
│ "password": "",
│ "port": 5432,
│ "privs": "EXECUTE",
│ "roles": "docker-service",
│ "schema": "pg_catalog",
│ "session_role": null,
│ "ssl_cert": null,
│ "ssl_key": null,
│ "ssl_mode": "prefer",
│ "state": "present",
│ "target_roles": null,
│ "trust_input": true,
│ "type": "function"
│ }
│ },
│ "msg": "Cannot execute SQL 'GRANT EXECUTE ON function \"pg_catalog\".\"pg_start_backup\"(label text, fast boolean) TO \"docker-service\";': function pg_catalog.pg_start_backup(text, boolean) does not exist\n"
│ }

```

but when i try with the following ansible:

```auto
  - name: GRANT EXECUTE on function pg_start_backup
    community.postgresql.postgresql_privs:
      database: postgres
      privs: EXECUTE
      schema: pg_catalog
      objs: "pg_start_backup"
      type: function
      roles: ${dockeruser}
      login_user: ${db_admin_user}
      login_password: ${db_admin_password}
      login_host: localhost

```

i get the following error:

```auto
│ "changed": false,
│ "invocation": {
│ "module_args": {
│ "ca_cert": null,
│ "connect_params": {},
│ "database": "postgres",
│ "fail_on_role": true,
│ "grant_option": null,
│ "login_host": "localhost",
│ "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
│ "login_unix_socket": "",
│ "login_user": "postgres",
│ "objs": "pg_start_backup",
│ "password": "",
│ "port": 5432,
│ "privs": "EXECUTE",
│ "roles": "docker-service",
│ "schema": "pg_catalog",
│ "session_role": null,
│ "ssl_cert": null,
│ "ssl_key": null,
│ "ssl_mode": "prefer",
│ "state": "present",
│ "target_roles": null,
│ "trust_input": true,
│ "type": "function"
│ }
│ },
│ "msg": "Illegal function / procedure signature: \"pg_start_backup\"."
│ }

```

i have search through internet and chatgpt for an example but my skills fails me 🙂

i tried to grant for a function that has no paramters `pg_backend_pid`

```auto
  - name: GRANT EXECUTE on function pg_start_backup
    community.postgresql.postgresql_privs:
      database: postgres
      privs: EXECUTE
      schema: pg_catalog
      objs: "pg_backend_pid()"
      type: function
      roles: ${dockeruser}
      login_user: ${db_admin_user}
      login_password: ${db_admin_password}
      login_host: localhost

```

which succeeds

---

<div class="post-metadata">

**Author:** ![Cepxio](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cepxio/32/1458_2.png) [@Cepxio](https://forum.ansible.com/u/Cepxio)\
**Post date:** [May 31, 2024, 2:10pm UTC](https://forum.ansible.com/t/how-to-grant-execute-on-pg-backup-start/6105/2 "2024-05-31T14:10:56Z")

</div>

Hi Freddik,

I hope you are well,

It seems that the Postgres function name is not correct.

Please, look at the official docs [https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-BACKUP](https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-BACKUP)

---

<div class="post-metadata">

**Author:** ![svenna](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/svenna/32/3627_2.png) [@svenna](https://forum.ansible.com/u/svenna)\
**Post date:** [May 31, 2024, 2:41pm UTC](https://forum.ansible.com/t/how-to-grant-execute-on-pg-backup-start/6105/3 "2024-05-31T14:41:01Z")

</div>

hi sergio,

thanks!! i have read the same document and looked at the function signature in pgadmin without realizing that i had it wrong. the brain just switched the name to the correct.  
i copied it from a guide and it was for an older postregres.  
the worst thing is that i actually had changed the name to the correct spelling but had tried with another signature

anyway many thanks for your extra eyes. it is tested and works 🎉

---

<div class="post-metadata">

**Author:** ![Cepxio](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cepxio/32/1458_2.png) [@Cepxio](https://forum.ansible.com/u/Cepxio)\
**Post date:** [May 31, 2024, 4:19pm UTC](https://forum.ansible.com/t/how-to-grant-execute-on-pg-backup-start/6105/4 "2024-05-31T16:19:27Z")

</div>

Yes, the former way is deprecated, `pg_start_backup()` was added in [PostgreSQL 8.0](https://pgpedia.info/postgresql-versions/postgresql-8.0.html) and replaced in [PostgreSQL 15](https://pgpedia.info/postgresql-versions/postgresql-15.html) by `[pg_backup_start()](https://pgpedia.info/p/pg_backup_start.html)`.

I’m glad your PB is working well!!

Cheers!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 30, 2024, 4:19pm UTC](https://forum.ansible.com/t/how-to-grant-execute-on-pg-backup-start/6105/5 "2024-06-30T16:19:37Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
