Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda