1.建库、建表(create.bat)
2.备份、还原(backup.bat)
注:反斜线被转换掉,请在相应位置自行加上。
set
path
=
C:
Program
Files
PostgreSQL
8.2
bin
createdb 数据库名
psql -f 表名1 . sql -U postgres 数据库名
psql -f 表名2 . sql -U postgres 数据库名
psql -f 表名3 . sql -U postgres 数据库名
...
createdb 数据库名
psql -f 表名1 . sql -U postgres 数据库名
psql -f 表名2 . sql -U postgres 数据库名
psql -f 表名3 . sql -U postgres 数据库名
...
2.备份、还原(backup.bat)
set
path
=
C:
Program
Files
PostgreSQL
8.2
bin
set yy = % date :~ 0 , 4 %
set mm = % date :~ 5 , 2 %
set dd = % date :~ 8 , 2 %
mkdir C: data_backup
pg_dump -Fc -i -E UTF8 -O -x -h localhost -U postgres -f C: data_backup %yy%%mm%%dd% . backup 数据库名
cd C: data_backup
edit %yy%%mm%%dd% . bat
echo set path = C: Program Files PostgreSQL 8.2 bin ;>> %yy%%mm%%dd% . bat
echo pg_restore -c -d 数据库名 -h localhost -U postgres C: data_backup %yy%%mm%%dd% . backup >> %yy%%mm%%dd% . bat
set yy = % date :~ 0 , 4 %
set mm = % date :~ 5 , 2 %
set dd = % date :~ 8 , 2 %
mkdir C: data_backup
pg_dump -Fc -i -E UTF8 -O -x -h localhost -U postgres -f C: data_backup %yy%%mm%%dd% . backup 数据库名
cd C: data_backup
edit %yy%%mm%%dd% . bat
echo set path = C: Program Files PostgreSQL 8.2 bin ;>> %yy%%mm%%dd% . bat
echo pg_restore -c -d 数据库名 -h localhost -U postgres C: data_backup %yy%%mm%%dd% . backup >> %yy%%mm%%dd% . bat
注:反斜线被转换掉,请在相应位置自行加上。