for archive_command use an script rather than a command I want to create a configuration to get a PostgreSQL HA. In my Master I want to configure a postgresql.conf file with this:

archive_command = 'local_backup_script.sh "%p" "%f"'


instead of:

archive_command = 'cp "%p" /path/to/archive/"%f"'


Then I have a doubt: Where do I have to put the script?
You can put it wherever you like, so long as the postgres user has permission to execute it, and permission to cd into the directory it's in.

I usually put it in /usr/local/bin unless I'm working on a system that has a versioned repository of scripts, in which case it's in there - something like /opt/mycompany-scripts/postgresql/myarchivescript.sh.

I recommend using a fully qualified path to make its location obvious, e.g.

archive_command = '/usr/local/bin/pg_archive_wal.sh "%p" "%f"'


(calling it "backup script" is misleading; it isn't doing backups at all, it's just archiving WAL, which may be part of a backup or replication process).