0
I’m making a .Bat for Backup and one for Restore of a bank in Postegresql, the .Bat Backup works perfectly, however, Restore gives problem by database owning data.
Would have some way to start the .Bat of Restore excluding all tables and only leaving the BD not to make a mistake?
chdir C:\Program Files\PostgreSQL\9.4\bin
ECHO "C:\Program Files\PostgreSQL\9.4\bin"
ECHO.
SET caminho=C:\
SET database=DATABASE
SET PGPASSWORD=1234
FOR /F "TOKENS=1-4 delims=/ " %%I IN ('DATE /t') DO SET data=%%I-%%J-%%K
FOR /F "TOKENS=1-2* delims=: " %%A IN ('TIME /t') DO SET hora=%%Ah%%Bm
ECHO ***********************************************
ECHO Aguarde, realizando o Restore do Banco de Dados
ECHO ***********************************************
ECHO.
pg_restore -U postgres -d %database% -1 %caminho%%database%_%data%.backup
PAUSE
Use the --clean option in pg_dump which will generate the appropriate commands to clear your base before restoring it.
– anonimo