Browse Source

fix: [odoo-tecnativa] support restoring large database file

master
Valentin Lab 10 months ago
parent
commit
9aae43b4b0
  1. 31
      odoo-tecnativa/actions/load

31
odoo-tecnativa/actions/load

@ -160,26 +160,41 @@ check_input() {
}
}
## Beware that we are not on the host, so we need to create the
## fifo in a place we can share with the curl container.
export TMPDIR=/var/cache/compose
settmpdir RESTORE_TMPDIR
mkfifo "$RESTORE_TMPDIR/fifo"
## Using fifo because if using ``@-`` curl will load all the database
## in memory before sending it, which is NOT desirable as the size of
## the database can be greater than available memory. Using fifo, we
## force the data to be streamed.
cmd=(
docker run -i --rm --network "$container_network"
-v "$RESTORE_TMPDIR/fifo:/tmp/restore/fifo"
"$DEFAULT_CURL_IMAGE"
-sS
-X POST
-F "master_pwd=${ADMIN_PASSWORD}"
-F "backup_file=@-"
-sS
-X POST
-F "master_pwd=${ADMIN_PASSWORD}"
-F "name=${dbname}"
"${curl_opts[@]}"
-F "backup_file=@/tmp/restore/fifo"
http://${container_ip}:8069/web/database/restore
)
)
## XXXvlab: contains password, left only for advanced debug
#debug "${cmd[@]}"
#echo "COMMAND: ${cmd[@]}" >&2
out=$(set -o pipefail; check_input | "${cmd[@]}") || {
"${cmd[@]}" > "$RESTORE_TMPDIR/out" &
pid=$!
check_input > "$RESTORE_TMPDIR/fifo"
wait "$pid" || {
die "Posting to odoo restore API through curl was unsuccessfull."
}
out=$(cat "$RESTORE_TMPDIR/out")
if [[ "$out" == *"<html>"* ]]; then
errmsg=$(echo "$out" | grep "alert-danger")
errmsg=${errmsg#*>}

Loading…
Cancel
Save