Hi Andrus, > On 01. Jun, 2020, at 12:26, Andrus <kobruleht2@xxxxxx> wrote: > My script does the same thing as your comands. no, it does not. And as long as you refuse to understand that, I can't help you. > I want to create replication server. no, you want to create a streaming replica. > Old cluster is empty, from initdb. Backup is not needed then why the mv stuff? > pg_basebackup uses environment varuables if not specified in command line. So my script does the same thing. have you looked at the other options? > I tried > sudo --user=postgres pg_basebackup .... > but got error > could not change directory to "/root": Permission denied try sudo su - postgres pg_basebackup .... Note the "-"! It's essential to get the environment of postgres, which is what you want. Cheers, Paul