pg_dumpバックアップデータ

2333 ワード

pg_dump -U admin -a --column-inserts -t
Insertで表示すると、コンソールが文字化けしてファイルに出力するように変更すればよい
データベースをバックアップし、insertで出力します.
@echo off
echo execute pg_dump
set /p dbname=please input database name:
echo dump database is %dbname%
f:\pgsql\pgsql9.1.4\bin\pg_dump.exe --file %dbname%.sql --host=localhost --port=5432 -U admin -a --column-inserts %dbname%
echo done!
pause

コピーしてbatに保持し、実行すればよい.
投稿:http://xiaofengtoo.iteye.com/blog/1815129
@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  !