odoo / docker

Other
931 stars 1.51k forks source link

[bug] Odoo 14 & 15: Unable to do ZIP backups through the Database Manager #467

Closed Pexers closed 3 months ago

Pexers commented 9 months ago

Odoo versions 14.0 and 15.0 are prompting the below error when doing database backups through the Database Manager.

INFO odoo odoo.service.db: DUMP DB: odoo format zip ERROR odoo odoo.addons.web.controllers.main: Database.backup Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1180, in backup dump_stream = odoo.service.db.dump_db(name, None, backup_format) File "", line 2, in dump_db File "/usr/lib/python3/dist-packages/odoo/service/db.py", line 41, in if_db_mgt_enabled return method(self, *args, *kwargs) File "/usr/lib/python3/dist-packages/odoo/service/db.py", line 241, in dump_db odoo.tools.exec_pg_command(cmd) File "/usr/lib/python3/dist-packages/odoo/tools/misc.py", line 130, in exec_pg_command raise Exception('Postgres subprocess %s error %s' % (args2, rc)) Exception: Postgres subprocess ('/usr/bin/pg_dump', '--no-owner', '--file=/tmp/tmpvf1eij64/dump.sql', 'odoo') error 1

Steps to Reproduce

  1. Start PSQL and Odoo 15.0 or 14.0 containers:
    $ docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name db postgres:15
    $ docker run -p 8069:8069 --name odoo --link db:db -t odoo:15.0
  2. Access the database manager at: http://localhost:8069/web/database/manager
  3. Try to do a ZIP backup of the database.

Possible Implementation

Some PSQL Debian packages were recently updated, so they might need to be installed without using the latest version in order to make this feature work again (not tested):

E4eqRL0yw0yajQJ433QL commented 9 months ago

I am experiencing this exact same issue since I installed the [REF] Odoo 14.0-16.0: update to release 20230925. I am running odoo 14 with a separate postgres:15 container (15.4-2pgdg120+1)

kevinberger-ch commented 9 months ago

I also have the same problem. The pg_dump version seems to have changed from 15.4 (Debian 15.4-1.pgdg110+1) to 16.0 (Debian 16.0-1.pgdg110+1). which is why they are now incompatible with the postgres server (in my case with the latest postgres:14 Image 14.9 (Debian 14.9-1.pgdg120+1)

kirillk0 commented 9 months ago

Same problem. I can log into the container and use the _dump, it works. Like this: docker exec -it container_name /bin/sh /usr/bin/pg_dump -h db --no-owner --file /tmp/dump.sql db_name So it's probably not a client version issue. And since it works when I run it manually, I can't see the actual error text. "pg_dump custom format" option is also works.

kevinberger-ch commented 9 months ago

Same problem. I can log into the container and use the _dump, it works. Like this: docker exec -it container_name /bin/sh /usr/bin/pg_dump -h db --no-owner --file /tmp/dump.sql db_name So it's probably not a client version issue. And since it works when I run it manually, I can't see the actual error text. "pg_dump custom format" option is also works.

Yes, you are right, even with the new pg_dump version pg_dump (PostgreSQL) 16.0 (Debian 16.0-1.pgdg110+1) I am able to use pg_dump manually with the command you provided. Sorry for my wrong statement, i should have checked.

kirillk0 commented 9 months ago

Ok, I finally found that the problem is with the client version. Replacing postgresql-client with postgresql-client-15 in line 49 of Dockerfile fixes the problem. Still no idea why launching newer pg_dump manually works, but backup via UI does not work&

E4eqRL0yw0yajQJ433QL commented 9 months ago

Thanks Kirill !!! Yes this is definitely a viable solution (albeit a temporary one). It took me a while to translate your solution into a working system as I am an absolute noob. What worked for me was to (re)run the source code from the docker file in the container itsself (I have installed docker on my NAS and have a odoo14 container and a postgres15 container). Note: the code below is specific for the image for odoo14 (which runs on debian-buster) and will need slight adjustment for other odoo images:

1. Access NAS in command line editor mode using (e.g.) putty

2. Open a bash in the odoo14 container:

sudo docker container ls
sudo docker exec -it -u root [CONTAINER_ID] bash

3. Run the code from the docker file (replacing postgresql-client with postgresql-client-15 as per your instructions)

echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' > /etc/apt/sources.list.d/pgdg.list
GNUPGHOME="$(mktemp -d)"
export GNUPGHOME
repokey='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8'
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}"
gpg --batch --armor --export "${repokey}" > /etc/apt/trusted.gpg.d/pgdg.gpg.asc
gpgconf --kill all
rm -rf "$GNUPGHOME"
apt-get update
apt-get install --no-install-recommends -y postgresql-client-15
rm -f /etc/apt/sources.list.d/pgdg.list
rm -rf /var/lib/apt/lists/*

5. Remove postgresql-client-16 apt remove postgresql-client-16 -y

6. Finally restart the odoo14 container

I just tested this and this has resolved the issue (for now). Database export with webclient works as before. This seems like a temporary fix and it is likely that this solution won't work on a postgresql database version 16. Hope that a real root-cause solution will be implemented in one of the next releases. However for now, I couldn't be happier. It was extremely uncomfortable not knowing how to create proper backup.

kevinberger-ch commented 8 months ago

Thanks @E4eqRL0yw0yajQJ433QL and @kirillk0! And for those who need it (like me): here is a dockerfile to build a working odoo image (again).

FROM odoo:15

# execute as root
USER root

# install postgresql-client-15
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main' > /etc/apt/sources.list.d/pgdg.list \
    && GNUPGHOME="$(mktemp -d)" \
    && export GNUPGHOME \
    && repokey='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8' \
    && gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}" \
    && gpg --batch --armor --export "${repokey}" > /etc/apt/trusted.gpg.d/pgdg.gpg.asc \
    && gpgconf --kill all \
    && rm -rf "$GNUPGHOME" \
    && apt-get update  \
    && apt-get install --no-install-recommends -y postgresql-client-15 \
    && rm -f /etc/apt/sources.list.d/pgdg.list \
    && rm -rf /var/lib/apt/lists/*

# remove postgresql-client-16
RUN apt remove postgresql-client-16 -y

I also hope for a real root-cause solution soon!

ZOOUQinn commented 8 months ago

The image of odoo 15.0 create 3 days ago (id: 64b664a48f44) didn't not fix this issue. Is there schedule for pushing the new image which had been corrected?

crossmax commented 8 months ago

I've been trying to solve this problem for a whole day and I can't resolve it in any way. I get this error when trying to install postgres-client-15 postgresql-client-15 : Depends: libreadline7 (>= 6.0) but it is not installable

I'm using docker-compose with odoo:15 and postgres:latest (postgres:16 with same error too). If is a common error, how you realize the backups?

E4eqRL0yw0yajQJ433QL commented 7 months ago

Hi Pedro (Pexers), since you closed the issue I am assuming that you found a root-cause for this problem. Would it be possible to share your solution? For me the issue hasn't disappeared: I just retested and in my case I am still very much getting the error as in your original post. Fortunately the solution that was posted still acts as workaround and (temporarily) fixes the issue.

Context: I created the odoo14 container using the CLI: sudo docker run -d --name=odoo14 --link odoo14-db:db -p 48069:8069 -p 48071:8071 -p48072:8072 -v /volume1/docker/odoo14/appserver/:/var/lib/odoo -v /volume1/docker/odoo14/config/:/etc/odoo --restart unless-stopped odoo:14

Pexers commented 7 months ago

@E4eqRL0yw0yajQJ433QL My apologies, I shouldn't have had closed the issue without a commit to fix it.

Nevertheless, on my side I have a custom Dockerfile where I just had to specify postgresql-client-15 to be installed for versions 14.0 and 15.0 instead of postgresql-client, just like @kevinberger-ch pointed out.

ZOOUQinn commented 7 months ago

Eventually, the issue was fixed.

E4eqRL0yw0yajQJ433QL commented 7 months ago

Thanks for warning us. I just retested this issue and there is a difference between odoo14, odoo15 and odoo16:

I am not sure if the fix was caused by an update of the underlying linux version (odoo14 = debian-buster, odoo15 = debian-bullseye, odoo16 = debian-bullseye, odoo17 = ubuntu-jammy) or if something has changed in the dockerfile.

I am quite sure that the issue has now permanently been resolved for odoo15 and higher. However I am not so sure if we can expect a real root-cause fix for odoo14 anymore. Personally I am happy for now, as I'll be upgrading to odoo15 (in combination with postgres16) soon.

lathama commented 3 months ago

@Pexers is there anything needed here? Can this issue be closed?

Pexers commented 3 months ago

@lathama Yes, just finished re-testing it and no issues found. Thanks for the feedback everyone!