您可以转储单个数据表,如下所示:
$ pg_dump --no-acl --no-owner -h [host ip].compute-1.amazonaws.com -U [user name] -t [table name] --data-only [database name] > table.dump
您可以获得以下所需的所有值:
$ heroku pg:credentials [DATABASE] -a [app_name] Connection info string: "dbname=[database name] host=[host ip].compute-1.amazonaws.com port=5432 user=[user name] password=[password] sslmode=require" Connection URL: postgres://[username]:[password]@[host ip].compute-1.amazonaws.com:5432/[database name]
这将提示您输入密码。输入它,然后您应该继续在本地驱动器上获取一个文件table.dump。
你可能想要在分段上截断表:
$ echo "truncate [table];" | heroku pg:psql [DATABASE] -a staging_app
使用该文件,您可以使用psql与连接URL:输出新的调用pg:凭据为分段应用程序,并只恢复该表。
$ psql "[pasted postgres:// from pg:credentials of staging app]" < table.dump SET SET ... ... ... ... $