Postgresql backup & restore command
Auth
把 authentication 資訊寫在 ~/.pgpass
,格式如下:
1 | host:port:database:user:password |
在用 pg_dump
跟 psql
時就可以不用輸入密碼。
當然這個檔案的權限要是 600
。
Backup
1 | $ pg_dump \ |
Restore
1 | psql -d [DBNAME] -f [SQL_FILE_PATH] -h [HOST] -p [PORT] -U [USER] |