postgresql bat备份sql
postgresql bat备份sql
Java代码 www.zzzyk.com
@echo off
e:
cd E:\PostgreSQL\PostgreSQL\bin\
set server=192.168.1.99
set post=5432
set username=test
set schema="\"test"\"
set catalog="test"
::: 获取时间
set datevar=%date:~0,4%%date:~5,2%%date:~8,2%
set timevar=%time:~0,2%
if /i %timevar% LSS 10 (
set timevar=0%time:~1,1%
)
set timevar=%timevar%%time:~3,2%%time:~6,2%
set datetime=%datevar%%timevar%
set file=C:\Users\Administrator\Desktop\%datetime%.sql
rem single table_scripte and data
rem pg_dump.exe --host %server% --port %post% --username %username% --no-password --verbose --table ge_game_type --column-inserts --file %file% --schema %schema% %catalog%
rem single table_scripte
rem pg_dump.exe --host %server% --port %post% --username %username% --no-password --verbose --table tt_test2 --schema-only --file %file% --schema %schema% %catalog%
rem all script
pg_dump.exe --host %server% --port %post% --username %username% --no-password --verbose --schema-only --file %file% --schema %schema% %catalog%
rem all script and data
rem pg_dump.exe --host %server% --port %post% --username %username% --encoding UTF8 --no-password --verbose --column-inserts --file %file% --schema %schema% %catalog%
rem single table data
rem pg_dump.exe --host %server% --port %post% --username %username% --no-password --data-only --verbose --table ge_game_type --column-inserts --file %file% --schema %schema% %catalog%
rem all table data
rem pg_dump.exe --host %server% --port %post% --username %username% --no-password --data-only --verbose --column-inserts --file %file% --schema %schema% %catalog%
@echo 备份完成!