From 1e6a4c058a5365cf96b1932f692093292f3d7774 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 20 Dec 2023 16:23:01 +0100 Subject: [PATCH] new: [vps] add support of ``--neutralize`` (or ``-n``) to ``vps odoo restore`` --- README.org | 3 +++ bin/vps | 30 ++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.org b/README.org index f52836a..7fe8c3f 100644 --- a/README.org +++ b/README.org @@ -461,6 +461,9 @@ vps odoo restore /tmp/db.zip -s odoo2 ## restore 'odoodev' database of default 'odoo' service vps odoo restore /tmp/db.zip -d odoodev + +## restore on database of default 'odoo' service, and neutralize the restored base +vps odoo restore -n /tmp/db.zip #+end_src ****** Via standard charm action diff --git a/bin/vps b/bin/vps index bb22f2e..5f1fcd5 100755 --- a/bin/vps +++ b/bin/vps @@ -1604,7 +1604,9 @@ cmdline.spec:odoo:cmd:restore:run() { (can be a local file or an url)' : :optval: --service,-s "The service (defaults to 'odoo')" - : :optval: --database,-d 'Target database (default if not specified)' + : :optval: --database,-D 'Target database (default if not specified)' + : :optfla: --neutralize,-n "Restore database in neutralized state." + : :optfla: --debug,-d "Display more information." local out @@ -1633,21 +1635,37 @@ cmdline.spec:odoo:cmd:restore:run() { exit 1 } + opts_compose=() + [ -t 1 ] && opts_compose+=("--color") + [ "$opt_debug" ] && { + VERBOSE=1 + opts_compose+=("--debug") + } + opts_load=() + [ "$opt_neutralize" ] && opts_load+=("--neutralize") + #cmdline.spec:odoo:cmd:restart:run --service "$odoo_service" || exit 1 msg_dbname=default [ -n "$opt_database" ] && msg_dbname="'$opt_database'" - compose --no-hooks drop "$odoo_service" $opt_database || { - err "Error dropping $msg_dbname database of service ${DARKYELLOW}$odoo_service${NORMAL}." + Wrap -vsd "drop $msg_dbname database of service ${DARKYELLOW}$odoo_service${NORMAL}" -- \ + compose --no-hooks "${opts_compose[@]}" drop "$odoo_service" $opt_database || { + err "Error dropping $msg_dbname database of service ${DARKYELLOW}$odoo_service${NORMAL}:" + [ -z "$opt_debug" ] && { + echo " Use \`\`--debug\`\` (or \`\`-d\`\`) to get more information." >&2 + } exit 1 } - compose --no-hooks load "$odoo_service" $opt_database < "$ZIP_DUMP_LOCATION" || { + Wrap -vsd "restore $msg_dbname database of service ${DARKYELLOW}$odoo_service${NORMAL}" -- \ + compose --no-hooks "${opts_compose[@]}" \ + load "$odoo_service" $opt_database "${opts_load[@]}" < "$ZIP_DUMP_LOCATION" || { err "Error restoring service ${DARKYELLOW}$odoo_service${NORMAL} to $msg_dbname database." + [ -z "$opt_debug" ] && { + echo " Use \`\`--debug\`\` (or \`\`-d\`\`) to get more information." >&2 + } exit 1 } - info "Successfully restored ${DARKYELLOW}$odoo_service${NORMAL} to $msg_dbname database." - ## Restart odoo, ensure there is no bugs lingering on it. cmdline.spec:odoo:cmd:restart:run --service "$odoo_service" || exit 1