hmm
This commit is contained in:
1 parent
01f4ae8eea
commit
ef641e9fe2
3 files changed
+69
-5
No files matched your search
@@ -35,6 +35,14 @@ else
|
||||
fi
|
||||
|
||||
|
||||
source /4server/sbin/ODOO_19/ODOO_19.lib
|
||||
|
||||
# Abort BEFORE touching anything if Postgres is not reachable
|
||||
if ! wait_for_postgres; then
|
||||
echo "ERROR: cannot connect to Postgres at $POSTGRES_HOST:$POSTGRES_PORT - restore aborted, nothing was changed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### DELETE AND CREATE DATABASE
|
||||
PGPASSWORD="$POSTGRES_ADMIN_PASSWORD" psql -h "$POSTGRES_HOST" -U "$POSTGRES_ADMIN_USER" -d postgres -c "
|
||||
SELECT pg_terminate_backend(pid) FROM pg_stat_activity
|
||||
@@ -49,10 +57,21 @@ PGPASSWORD="$POSTGRES_ADMIN_PASSWORD" psql \
|
||||
-c "ALTER ROLE \"$UUID\" CREATEDB;"
|
||||
|
||||
|
||||
doas docker exec "$UUID" rm -rf /home/odoo/.local/share/Odoo/filestore
|
||||
# Move the old filestore aside instead of deleting it; it is only removed after a successful load
|
||||
OLD_FS="/home/odoo/.local/share/Odoo/.filestore.pre-restore"
|
||||
doas docker exec "$UUID" rm -rf "$OLD_FS"
|
||||
doas docker exec "$UUID" sh -c "[ -d /home/odoo/.local/share/Odoo/filestore ] && mv /home/odoo/.local/share/Odoo/filestore $OLD_FS; true"
|
||||
doas docker exec "$UUID" rm -rf /root/.local/share/Odoo/filestore
|
||||
|
||||
doas docker exec "$UUID" odoo db --db_host beedb -w "$ODOO_DB_PASSWORD" -r "$UUID" load "$UUID" $FILENAME -f
|
||||
if ! doas docker exec "$UUID" odoo db --db_host beedb -w "$ODOO_DB_PASSWORD" -r "$UUID" load "$UUID" $FILENAME -f; then
|
||||
echo "ERROR: odoo db load failed - putting the old filestore back"
|
||||
doas docker exec "$UUID" sh -c "[ -d $OLD_FS ] && rm -rf /home/odoo/.local/share/Odoo/filestore && mv $OLD_FS /home/odoo/.local/share/Odoo/filestore; true"
|
||||
PGPASSWORD="$POSTGRES_ADMIN_PASSWORD" psql \
|
||||
-h "$POSTGRES_HOST" -U "$POSTGRES_ADMIN_USER" -p "$POSTGRES_PORT" -d postgres \
|
||||
-c "ALTER ROLE \"$UUID\" NOCREATEDB;"
|
||||
exit 1
|
||||
fi
|
||||
doas docker exec "$UUID" rm -rf "$OLD_FS"
|
||||
|
||||
PGPASSWORD="$POSTGRES_ADMIN_PASSWORD" psql \
|
||||
-h "$POSTGRES_HOST" -U "$POSTGRES_ADMIN_USER" -p "$POSTGRES_PORT" -d postgres \
|
||||
|
||||
Reference in new issue
Block a user