10000 Support skipping extensions & filtering in pgcopydb dump/restore cli by arajkumar · Pull Request #572 · dimitri/pgcopydb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support skipping extensions & filtering in pgcopydb dump/restore cli #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/bin/pgcopydb/cli_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static CommandLine dump_schema_command =
" --source Postgres URI to the source database\n"
" --target Directory where to save the dump files\n"
" --dir Work directory to use\n"
" --skip-extensions Skip restoring extensions\n" \
" --snapshot Use snapshot obtained with pg_export_snapshot\n",
cli_dump_schema_getopts,
cli_dump_schema);
Expand All @@ -50,6 +51,7 @@ static CommandLine dump_schema_pre_data_command =
" --source Postgres URI to the source database\n"
" --target Directory where to save the dump files\n"
" --dir Work directory to use\n"
" --skip-extensions Skip restoring extensions\n" \
" --snapshot Use snapshot obtained with pg_export_snapshot\n",
cli_dump_schema_getopts,
cli_dump_schema_pre_data);
Expand Down Expand Up @@ -109,6 +111,7 @@ cli_dump_schema_getopts(int argc, char **argv)
{ "no-role-passwords", no_argument, NULL, 'P' },
{ "restart", no_argument, NULL, 'r' },
{ "resume", no_argument, NULL, 'R' },
{ "skip-extensions", no_argument, NULL, 'e' },
{ "not-consistent", no_argument, NULL, 'C' },
{ "snapshot", required_argument, NULL, 'N' },
{ "version", no_argument, NULL, 'V' },
Expand Down Expand Up @@ -189,6 +192,13 @@ cli_dump_schema_getopts(int argc, char **argv)
break;
}

case 'e':
{
options.skipExtensions = true;
log_trace("--skip-extensions");
break;
}

case 'C':
{
options.notConsistent = true;
Expand Down Expand Up @@ -391,13 +401,13 @@ cli_dump_schema_section(CopyDBOptions *dumpDBoptions,
{
log_info("Using pg_dumpall for Postgres \"%s\" at \"%s\"",
pgPaths->pg_version,
pgPaths->pg_dump);
pgPaths->pg_dumpall);
}
else
{
log_info("Using pg_dump for Postgres \"%s\" at \"%s\"",
pgPaths->pg_version,
pgPaths->pg_dumpall);
pgPaths->pg_dump);
}

/*
Expand Down
6 changes: 5 additions & 1 deletion src/bin/pgcopydb/cli_restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ static CommandLine restore_schema_pre_data_command =
" --no-owner Do not set ownership of objects to match the original database\n"
" --no-acl Prevent restoration of access privileges (grant/revoke commands).\n"
" --no-comments Do not output commands to restore comments\n"
" --skip-extensions Skip restoring extensions\n" \
" --skip-ext-comments Skip restoring COMMENT ON EXTENSION\n" \
" --filters <filename> Use the filters defined in <filename>\n"
" --restart Allow restarting when temp files exist already\n"
" --resume Allow resuming operations after a failure\n"
Expand All @@ -83,6 +85,8 @@ static CommandLine restore_schema_post_data_command =
" --no-owner Do not set ownership of objects to match the original database\n"
" --no-acl Prevent restoration of access privileges (grant/revoke commands).\n"
" --no-comments Do not output commands to restore comments\n"
" --skip-extensions Skip restoring extensions\n" \
" --skip-ext-comments Skip restoring COMMENT ON EXTENSION\n" \
" --filters <filename> Use the filters defined in <filename>\n"
" --restart Allow restarting when temp files exist already\n"
" --resume Allow resuming operations after a failure\n"
Expand Down Expand Up @@ -691,7 +695,7 @@ cli_restore_prepare_specs(CopyDataSpec *copySpecs)
if (!copydb_fetch_schema_and_prepare_specs(copySpecs))
{
/* errors have already been logged */
exit(EXIT_CODE_SOURCE);
exit(EXIT_CODE_TARGET);
}

copySpecs->section = DATA_SECTION_NONE;
Expand Down
0