I'm trying out this tutorial which is made for linux postgresql server. I followed the configuration set ups but I dont know how to translate this command in windows. Also, whats the equivalent of /etc folder and /var folder in windows installation of postgres?
echo Stopping PostgreSQL
sudo service postgresql stop
echo Cleaning up old cluster directory
sudo -u postgres rm -rf /var/lib/postgresql/9.2/main
echo Starting base backup as replicator
sudo -u postgres pg_basebackup -h 1.2.3.4 -D /var/lib/postgresql/9.2/main -U
replicator -v -P
echo Writing recovery.conf file
sudo -u postgres bash -c "cat > /var/lib/postgresql/9.2/main/recovery.conf
<<- _EOF1_
standby_mode = 'on'
primary_conninfo = 'host=1.2.3.4 port=5432 user=replicator
password=thepassword sslmode=require'
trigger_file = '/tmp/postgresql.trigger'
_EOF1_"
echo Startging PostgreSQL
sudo service postgresql start
The full tutorial is here
My answer assumes several things that you did not tell us:
c:\Program Files\PostgreSQL\9.6postgresql-x64-9.6c:\ProgramData\Postgres\9.6So the script in your question would be roughly like the following:
rem add the Postgres bin directory to the path
rem so that references to the utilities do not
rem need to be full qualified
PATH=%PATH%;c:\Program Files\PostgreSQL\9.6\bin
rem Adjust to the real service name here
echo Stopping PostgreSQL
net stop postgresql-x64-9.6
echo Cleaning up old cluster directory
rem Adjust the data directory to your environment
rem You can check the current service configuration
rem to see where the data directory is
set DATADIR=c:\ProgramData\Postgres\9.6
rmdir /s /q "%DATADIR%"
echo Creating base backup
rem adjust IP address and username according to your master server
rem with 9.6 pg_basebackup can create the recovery.conf automatically
pg_basebackup -h 1.2.3.4 -D "%DATADIR%" -U replicator -v -P --write-recovery-conf -X stream
echo Starting PostgreSQL
net start postgresql-x64-9.6
Again: you have to adjust paths and names to your environment!