pg_dump 的文件输出在 MacOS 上去哪里?

Where does the file output of pg_dump go on MacOS?

psql 中,我只是 运行 命令 pg_dump 到自定义格式的存档:

Kurts-MacBook-Pro-2:~ kurtpeek$ psql --host localhost.aptible.in --port 64186 --username aptible --dbname db
Password for user aptible: 
psql (10.4, server 10.3 (Debian 10.3-1.pgdg80+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

db=# pg_dump --format=custom
db-# 

据我了解,这应该是将数据库(其名称是从环境变量PGDATABASE中获取的,这里大概是db)备份到一个文件中。但是,我不清楚该文件位于何处?

来自 --file 选项的文档 (https://www.postgresql.org/docs/10/static/app-pgdump.html),

-f file

--file=file

Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.

我想 custom 格式是基于文件的格式,所以我希望使用 'standard output'。但是在这种情况下 'standard output' 是什么? (我检查了我的主目录,但最近没有在其中创建任何内容)。

原来pg_dump命令是要在命令行使用的,而不是psql。事实上 'standard output' 打印到终端(在我的例子中这不是我想要的,因为我想使用 pg_restore 在本地恢复数据库)。

所以我创建了一个文件 (latest.dump) 并写信给它指定连接选项,以及 --format=custom--file=latest.dump:

Kurts-MacBook-Pro-2:~ kurtpeek$ touch latest.dump
Kurts-MacBook-Pro-2:~ kurtpeek$ pg_dump --host=localhost.aptible.in --port=64186 --username=aptible --dbname=db --format=custom --file=latest.dump
Password: 
Kurts-MacBook-Pro-2:~ kurtpeek$