Browse Source

new: [vps] add support of ``--neutralize`` (or ``-n``) to ``vps odoo restore``

master
Valentin Lab 4 months ago
parent
commit
1e6a4c058a
  1. 3
      README.org
  2. 30
      bin/vps

3
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

30
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

Loading…
Cancel
Save