Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

216
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda