PostgreSQL 数据库转储位置

PostgreSQL DB dump location

我想从 Ubuntu 16.04 服务器下载转储的 PostgreSQL 数据库。

sudo su - postgres
pg_dump my_db > backup_db

搜索路径得到以下结果:

ps auxw |  grep postgres | grep -- -D
postgres  7311  0.0  0.0 293332  3384 ?        S    Mai04   0:39 /usr/lib/postgresql/9.5/bin/postgres -D /var/lib/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf

但是我在那里找不到转储的文件。转储文件的位置是什么?

$HOME 用户 postgres

pg_dump just echoes to stdout,除非您指定 -f

-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.

(格式化我的)

所以在你的案例中文件 backup_db 将在你所在的同一目录中 运行 pg_dump my_db > backup_db

下次尝试指定完整路径以了解确切位置