Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make restore more robust #10

Merged
merged 3 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -1,20 +0,0 @@
CVE-2018-1330
CVE-2019-0205
CVE-2020-13949
CVE-2021-22569
CVE-2021-22570
CVE-2021-31684
CVE-2022-25647
CVE-2022-3509
CVE-2022-3510
CVE-2022-42003
CVE-2022-42004
CVE-2022-46337
CVE-2022-46751
CVE-2023-1370
CVE-2023-39410
CVE-2023-43642
CVE-2023-44981
CVE-2024-25710
CVE-2024-26308
GHSA-xpw8-rcwv-8f8p
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ trivy:
trivy image --ignore-unfixed odoo:latest

update-trivy-ignore:
trivy image --format json --ignore-unfixed --severity HIGH,CRITICAL flyte:latest | jq -r '.Results[1].Vulnerabilities[].VulnerabilityID' | sort -u | tee .trivyignore
trivy image --format json --ignore-unfixed --severity HIGH,CRITICAL odoo:latest | jq -r '.Results[1].Vulnerabilities[].VulnerabilityID' | sort -u | tee .trivyignore
36 changes: 29 additions & 7 deletions restore.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/bin/sh -e
#!/bin/bash

BASE_URL='http://localhost:8069'
MAX_ATTEMPTS=6
PROG=$( basename "$0" )

while getopts "a:d:f:u:" arg; do
while getopts "a:d:f:hm:u:" arg; do
case $arg in
a) ADMIN_PASSWORD="${OPTARG}" ;;
d) DB_NAME="${OPTARG}" ;;
f) FILE_NAME="${OPTARG}" ;;
h)
echo "usage: $( basname $0 ) -a admin_password -d db_name -u base_URL"
echo "usage: ${PROG} -a admin_password -d db_name -u base_URL"
exit 0
;;
m) MAX_ATTEMPTS="${OPTARG}" ;;
u) BASE_URL="${OPTARG}" ;;
*) exit 2 ;;
esac
Expand All @@ -36,8 +39,27 @@ if [ -z "$BASE_URL" ]; then
exit 1
fi

curl -s -F "master_pwd=${ADMIN_PASSWORD}" \
-F "name=${DB_NAME}" "${BASE_URL}/web/database/drop"
curl -s -F "master_pwd=${ADMIN_PASSWORD}" \
status=1
attempts=0

while (( status != 0 )); do
curl -sL --fail "${BASE_URL}/web_editor/static/src/xml/ace.xml" > /dev/null
status="$?"
(( attempts += 1 ))

if (( status == 0 )); then
echo "INFO: Odoo is ready for a restore."
elif (( attempts > MAX_ATTEMPTS )); then
echo "ERROR: Odoo not ready on ${BASE_URL}"
exit 1
else
echo "WARNING: Odoo on ${BASE_URL} is not ready (attempt ${attempts} of ${MAX_ATTEMPTS})."
sleep 10
fi
done

curl -sL -F "master_pwd=${ADMIN_PASSWORD}" \
-F "name=${DB_NAME}" "${BASE_URL}/web/database/drop" > /dev/null
curl --fail -sL -F "master_pwd=${ADMIN_PASSWORD}" \
-F "backup_file=@${FILE_NAME}" -F 'copy=true' \
-F "name=${DB_NAME}" "${BASE_URL}/web/database/restore"
-F "name=${DB_NAME}" "${BASE_URL}/web/database/restore" > /dev/null
Loading