Merge branch 'restore-sql' into 'main'
[ADD] restore-sql See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!74
This commit is contained in:
commit
5eed63ca56
|
|
@ -0,0 +1 @@
|
|||
Add option ``p`` (SQL format) allowing use from ``--database-format`` CLI. This allows you to restore database in SQL format (used by odoo full backup)
|
||||
|
|
@ -18,11 +18,11 @@ from odoo_openupgrade_wizard.tools.tools_system import restore_filestore
|
|||
@click.option(
|
||||
"--database-format",
|
||||
required=True,
|
||||
type=click.Choice(("c", "d", "t")),
|
||||
type=click.Choice(("c", "d", "t", "p")),
|
||||
default="c",
|
||||
help="Database format (see pg_dump options): "
|
||||
"custom format compressed (c), directory (d), tar file (t)."
|
||||
"plain sql text (p) is not implemented",
|
||||
"custom format compressed (c), directory (d), tar file (t),"
|
||||
" plain sql text (p).",
|
||||
)
|
||||
@click.option(
|
||||
"--filestore-path",
|
||||
|
|
|
|||
|
|
@ -250,15 +250,23 @@ def execute_pg_restore(
|
|||
container = get_postgres_container(ctx)
|
||||
ensure_database(ctx, database, "absent")
|
||||
ensure_database(ctx, database, "present")
|
||||
command = (
|
||||
"pg_restore"
|
||||
f" {Path('/env') / filepath}"
|
||||
f" --dbname={database}"
|
||||
" --schema=public"
|
||||
" --username=odoo"
|
||||
" --no-owner"
|
||||
f" --format {database_format}"
|
||||
)
|
||||
if database_format == "p":
|
||||
command = (
|
||||
"psql"
|
||||
f" --file='{Path('/env') / filepath}'"
|
||||
" --username odoo"
|
||||
f" --dbname={database}"
|
||||
)
|
||||
else:
|
||||
command = (
|
||||
"pg_restore"
|
||||
f" {Path('/env') / filepath}"
|
||||
f" --dbname={database}"
|
||||
" --schema=public"
|
||||
" --username=odoo"
|
||||
" --no-owner"
|
||||
f" --format {database_format}"
|
||||
)
|
||||
logger.info(f"Restoring database '{database}'...")
|
||||
pg_dump_result = exec_container(container, command)
|
||||
return pg_dump_result.output.decode("utf8")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user