- 註冊時間
- 2006-3-13
- 最後登錄
- 2025-1-10
- 在線時間
- 673 小時
- 閱讀權限
- 200
- 積分
- 417
- 帖子
- 1107
- 精華
- 0
- UID
- 2
  
|
1) 建立一個目錄 %APPDATA%\postgresql
在我的環境中為 C:\Documents and Settings\bestlong\Application Data\postgresql
2) 建立一個檔案 %APPDATA%\postgresql\pgpass.conf
可使用文字編輯程式如 Notepad
3) 輸入必要的設定在 %APPDATA%\postgresql\pgpass.conf
內容如下行
localhost:*:myDBname:myUserName:myPassword
4) 建立批次檔來執行備份或維護作業, 指令如下:
"C:\Program Files\PostgreSQL\8.0\bin\psql" -h localhost -d myDBname -U myUserName -f Name-Of-File-With-Maintenance-Commands
"C:\Program Files\PostgreSQL\8.0\bin\pg_dump" -f Name-Of-My-Dump-File -Fc -Z 9 -h localhost -U myUserName myDBname
5) Use the task scheduler to run your newly created batch file whenever you'd like it to run
I actually run my batch file every night. My DB has no activity during the night, so I run my maintenance then.
Name-Of-File-With-Maintenance-Commands contains SQL to refresh a materialized view and do a vacuum full analyze |
|