如何在 pg_dumpall 的输出中省略此角色创建部分:
--
-- Roles
--
CREATE ROLE admin;
ALTER ROLE admin WITH NOSUPERUSER INHERIT NOCREATEROLE CREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'SCRAM-SHA-';
CREATE ROLE user;
ALTER ROLE user WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'SCRAM-SHA-';
CREATE ROLE postgres;
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS PASSWORD 'SCRAM-SHA-';
CREATE ROLE zabbix;
ALTER ROLE zabbix WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'SCRAM-SHA-';
感谢您的任何提示。
如果使用带有 -v 选项的 grep 命令,则可以省略输出文件中不需要的行。例如,以下命令将从输出中排除 CREATE ROLE 行。
pg_dumpall -h (host) -U (username) | grep -v "CREATE ROLE" > roles_filtered.sql