//备份数据库
pg_dump "host=127.0.0.1 hostaddr=127.0.0.1 port=5432 user=postgres password=123456 dbname=postgres " >db.sql
//导出指定表的数据
pg_dump --data-only --file=./status.sql --table=status "host=127.0.0.1 hostaddr=127.0.0.1 port=5432 user=postgres password=123456 dbname=postgres"
//psql 查询数据并导出到csv 其中处理了jsonb字段中逗号
psql --csv -c "( SELECT id,ts,cate,kind,replace(replace(replace(data::text,'{','"{"'),'}','"}"'),',','","') as data from status) " -o ./status.csv "host=10.10.11.87 hostaddr=10.10.11.87 port=5432 user=postgres password=123456 dbname=2205_83"
//恢复数据库
psql -h 127.0.0.1 -U postgres -p 5432 -d postgres < db.sql;