Posted on 2008-11-25 10:13
Fingki.li 閱讀(3719)
評論(0) 編輯 收藏 所屬分類:
About linux
Backup to Script:
首先切換到postgres用戶:
liqingfeng@liqingfeng:~$ su postgres
口令: 輸入密碼
postgres@liqingfeng:/home/liqingfeng$
然后輸入backup命令:
pg_dump -U[username] -d -f[way of script file] [database name]
例如:pg_dump -Upostgres -d -f/home/liqingfeng/test.sql testdb
這樣數據庫testdb將以sql腳本形式backup到/home/liqingfeng/test.sql中。
Restore from Script:
還是首先要切換到postgres用戶下,輸入命令:
psql -U[username] -d[database name] -f[way to an existing script file]
例如:
psql -Upostgres -dtestdb -f/home/liqingfeng/test.sql