Merge branch 'restore-sql' into 'main'

[ADD] restore-sql

See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!74
This commit is contained in:
Rémy Taymans 2024-05-07 14:48:45 +00:00
commit 5eed63ca56
3 changed files with 21 additions and 12 deletions

View File

@ -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)

View File

@ -18,11 +18,11 @@ from odoo_openupgrade_wizard.tools.tools_system import restore_filestore
@click.option( @click.option(
"--database-format", "--database-format",
required=True, required=True,
type=click.Choice(("c", "d", "t")), type=click.Choice(("c", "d", "t", "p")),
default="c", default="c",
help="Database format (see pg_dump options): " help="Database format (see pg_dump options): "
"custom format compressed (c), directory (d), tar file (t)." "custom format compressed (c), directory (d), tar file (t),"
"plain sql text (p) is not implemented", " plain sql text (p).",
) )
@click.option( @click.option(
"--filestore-path", "--filestore-path",

View File

@ -250,6 +250,14 @@ def execute_pg_restore(
container = get_postgres_container(ctx) container = get_postgres_container(ctx)
ensure_database(ctx, database, "absent") ensure_database(ctx, database, "absent")
ensure_database(ctx, database, "present") ensure_database(ctx, database, "present")
if database_format == "p":
command = (
"psql"
f" --file='{Path('/env') / filepath}'"
" --username odoo"
f" --dbname={database}"
)
else:
command = ( command = (
"pg_restore" "pg_restore"
f" {Path('/env') / filepath}" f" {Path('/env') / filepath}"