Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
PostgreSQL Streaming Replication ubuntu commands to windows

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

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

My answer assumes several things that you did not tell us:

  • the Postgres version is 9.6 (9.2 is pretty outdated and will be end-of-live in 6 months)
  • Postgres (64bit) was installed to: c:\Program Files\PostgreSQL\9.6
  • you are using the default service name postgresql-x64-9.6
  • the data directory is c:\ProgramData\Postgres\9.6
  • you already have a Postgres 9.6 installation on a different (64bit) Windows system that should be the master for this replicated instance
  • your current Windows user that you use to run this has the necessary privileges to stop and start the service.

So 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!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!