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

Unable to create DB backup within docker container #12275

Closed
Petrievn opened this issue Jun 2, 2016 · 19 comments
Closed

Unable to create DB backup within docker container #12275

Petrievn opened this issue Jun 2, 2016 · 19 comments
Assignees
Labels
Confirmed the bug was confirmed by testers

Comments

@Petrievn
Copy link

Petrievn commented Jun 2, 2016

Impacted versions:
9.0

Steps to reproduce:

  • Install docker container (default installation)
  • Try to make a backup

Current behavior:

Gives error:

Database backup error: Postgres subprocess ('/usr/bin/pg_dump', '--no-owner', '--file=/tmp/tmpijZcLi/dump.sql', u'planetfeeds_db') error 1

Expected behavior:

Must succeed

Video/Screenshot link (optional):

@Yenthe666
Copy link
Collaborator

Yenthe666 commented Jun 3, 2016

@aab-odoo and @sle-odoo could you have a look at this one please?

@tesserB
Copy link
Contributor

tesserB commented Jun 4, 2016

@blaggacao I know you're pretty familiar with developing within docker... Any suggestions, sir?

@blaggacao
Copy link
Contributor

blaggacao commented Jun 4, 2016

We are working in an alpine linux implementation at the moment, we don't use odoo's official images.
However, this error doesn't seem docker specific.

I have had errors with pg_dump as it resides in the distribution's postgres packages, so the corresponding packages must be present. However as the official odoo image uses curl -o odoo.deb -SL http://nightly.odoo.com/${ODOO_VERSION}/nightly/deb/odoo_${ODOO_VERSION}c.${ODOO_RELEASE}_all.deb it is quite intransparent from this perspective what happens there.

EDIT: For further debugging I can recommend: docker exec -ti <runningcontainername> /bin/sh and poke around and invoke pg_dump manually. Note that pg_dump has an --verbose flag

@elicoidal
Copy link

elicoidal commented Jun 5, 2016

Since the Postgres client version to use is dependent of the Postgres server version, one of our developers created Python scripts that connect to a Postgres docker and use the Postgres client hosted inside.
Please find it at: https://github.com/ajite/docker-postgres-client

  1. To install and use it type the command below:
    $ pip install docker-postgres-client
  2. All the bash command have -C (container) option that you can use like below:
    $ dpsql -C <CONTAINER_NAME> -U odoo

Besides we have a specific postgresql 9.5 docker image (elicocorp/postgres:9.5)
Thanks to this simple tool we and the image we can very easily backup our postgres dockers from the outside world.

Example Script based on our image:

docker ps -q | xargs docker inspect --format '{{.Name}}'|grep postgres >/tmp/postgres_containers.txt
sed -i "s/\///g" /tmp/postgres_containers.txt
while IFS= read -r postgres_container; 
  do
    echo $log_src[`date +%F.%H:%M:%S`]' Backup Postgres containers '$postgres_container
    docker exec -t $postgres_container /mnt/script/pg_backup.sh bva; 
done < /tmp/postgres_containers.txt

echo $log_src[`date +%F.%H:%M:%S`]' Delete old pg_backup (> 3 days)'
sed -i "s/_postgres_1//g" /tmp/postgres_containers.txt
while IFS= read -r postgres_container; 
  do
    echo $log_src[`date +%F.%H:%M:%S`]' Delete old pg_backup for Postgres containers '$postgres_container
    find /mnt/data/backup/postgres/$postgres_container/* -maxdepth 0 -mtime +3 -exec rm {} \;
done < /tmp/postgres_containers.txt

rm /tmp/postgres_containers.txt

@blaggacao
Copy link
Contributor

blaggacao commented Jun 5, 2016

@elicoidal I was also wondering if @Petrievn is using a separate postgres, but as he mentions, he is using the official image, which if i remember correctly does no separation of concern and just packs the postgres into the dockerfile.

I would agree, that this is not even satisfying for development, but that's probably something that should be tackled apart.

EDIT: Just updated myself, those times are gone, that odoo packed postgres into the very same image. Then it's most probably a version mismatch indeed.

@blaggacao
Copy link
Contributor

There is also:
odoo/docker#49
odoo/docker#54

@elicoidal
Copy link

@blaggacao whether the images are together or not is important.
The point here is that it seems that the proposed official docker doesnot provide all the necessary tools.
Adding them in the image is probably the best option

@blaggacao
Copy link
Contributor

@elicoidal actually, I wa a bit out of date concerning the official image... 😄

@blaggacao
Copy link
Contributor

@Petrievn If those replies helped, consider closing this. I consider it more a "user error", than a design bug.

@tesserB
Copy link
Contributor

tesserB commented Jun 5, 2016

@Petrievn I doubt this will be open for much longer, as the GitHub issues section is reserved for bugs, but I want you to know that you're more than welcome to pick this up with us elsewhere:

Mailing Lists:
https://www.odoo.com/groups

Help Forum:
https://www.odoo.com/forum/help-1

Respectfully,
Cody K.
ckitterm@gmail.com

@elicoidal and @blaggacao - Thank you very much, gentlemen.

@Yenthe666 Sir.. ;-)

@Yenthe666
Copy link
Collaborator

Hi @Petrievn,

As stated by @blaggacao and @tesserB this is not really something related to the Github issues. I've kept this open in favor of the fact that you where talking about the official Odoo image for Docker. Since other people confirm this is not related to just this docker image I'm closing this one.
If you're still stuck with this and are facing issues have a look at the mailing lists and forums (as stated by Cody).
@Petrievn if you do not agree with this choice please comment on this topic and let me know why.

@tesserB thanks a lot for helping us out with issues. 👍

Regards,
Yenthe

@andersonkyle
Copy link

andersonkyle commented Jun 6, 2016

Problem

This most definitely isn't "User Error". The Odoo Docker image instructions are broken since they completely ignore this postgres version incompatbility.

The instructions tell users to start up a postgres database:

$ docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db postgres

Since this line omits the version tag, it defaults to latest which points to version 9.5

This version is incompatible with the Odoo Docker image since it points to the debian build which includes version 9.4. You may be fooled initially that things are okay since the Odoo server starts up. But when you need to backup the database, you're in for a rude awakening.

There are a few different ways to mitigate this issue

Solutions

  • Change the Odoo Docker image instructions to indicate that you need to use postgres:9.4 since the postgres client bundled with the debian build is also version 9.4
  • Update the Odoo Docker image to include postgres 9.5 so that it will work with the existing instructions out of the box.
  • Update the Odoo debian build to include postgres 9.5 so that it will work with the existing instructions out of the box.

Related

GitHub issues about this problem have been opened on this repo and the Odoo Docker repo without resolution:

49: Database backup
54: missing pg_dump tool
59: Database backup error

We can debate where this issue should live but make no mistake, this isn't User Error and needs to be addressed by Odoo officially.

@tesserB
Copy link
Contributor

tesserB commented Jun 6, 2016

@kanderson450 Well, I'm not going to fault you for your persistence—"closed mouths don't get fed"—but have you thought to submit a PR implementing any of your proposed solutions? And what about blaggacao' response to you?

"You need an manually updated odoo image, as it seems currently not covered by the odoo debian package, you could modify the apt-get install section and include postgres-client-9.5 , yet iirc it's not yet on the official apt repos, so you also need to include those repos first..."

I'm asking because if you want someone else to draft the changes to the doc, it would be helpful to know... In the meantime, I need to see a man about a taser...

(Psst, @aab-odoo or @mart-e, come quick! 4th issue on this —the natives are getting restless...)

@andersonkyle
Copy link

@tesserB I could absolutely submit a PR and would have already but this is the first time I've seen any real response to this issue on any of the open/closed issues. It would be nice to have the Odoo guys on the same page before writing a PR that will never be merged.

Do you work for Odoo or have write permissions to the repo? Let's all agree on the best approach to take.

This is tangentially related to: 10357 Postgresql 9.5 supported?

@Petrievn
Copy link
Author

Petrievn commented Jun 7, 2016

Hi there. Thank you for the replies. I am a layman in this field, hence
figuring out the comments take longer than usual.

On Mon, 06 Jun 2016, 22:21 kanderson450 notifications@github.com wrote:

@tesserB https://github.com/tesserB I could absolutely submit a PR and
would have already but this is the first time I've seen any real response
to this issue on any of the open/closed issues. It would be nice to have
the Odoo guys on the same page before writing a PR that will never be
merged.

Do you work for Odoo or have write permissions to the repo? Let's all
agree on the best approach to take.

This is tangentially related to: 10357 Postgresql 9.5 supported?
#10357


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#12275 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AKcrxLzQkbXaRhjhCfMBl8PQ-rNaIsBIks5qJIE-gaJpZM4IsuPQ
.

Kind regards/Vriendelike groete,

Petrie

@Yenthe666 Yenthe666 reopened this Jun 7, 2016
@Yenthe666 Yenthe666 added the Confirmed the bug was confirmed by testers label Jun 7, 2016
@Yenthe666
Copy link
Collaborator

@kanderson450 thanks a lot for the detailed answer, one of the best answers I've seen in a long time here. I've reopened this issue since this is indeed something that should be fixed by Odoo.
@mart-e, @odony and @aab-odoo can somebody please look at this? It has been reported by 4 people and looks like quite a big problem at this point.

odony added a commit to odoo/docker-docs that referenced this issue Jun 7, 2016
The odoo docker image is based on debian:jessie, which only has
postgresql-client-9.4, while the official postgres docker
is 9.5. This causes a version mismatch and errors when using the
postgres command-line tools, such as `pg_dump`.

Fixes odoo/odoo#12275
Fixes odoo/docker#49
Fixes odoo/docker#54
Fixes odoo/docker#59
@odony
Copy link
Contributor

odony commented Jun 7, 2016

Upstream PR to update the docker doc and explicitly pin the postgres docker image to 9.4: docker-library/docs#595
This is the simplest solution and since Odoo 9 is meant to be deployed with PG 9.4, it's in fact the correct one.

Regarding the other proposed solutions:

  • Our docker image is built (on purpose) on top of debian stable (currently debian:jessie), which does not have postgres 9.5. Our debian package depends on postgresql-client-9.4 for the same reason.
    Therefore installing postgresql-client-9.5 in our docker image would require some ugly steps. In addition, it would not survive the next upgrade of the postgres docker image (9.6 is around the corner).
    We'll gladly switch over to 9.5 when debian stable has it (debian:stretch will).
  • And we definitely cannot include PostgreSQL into the official Odoo docker image, the rules for official docker images require one image for one thing, and there is an official postgres docker image.

@andersonkyle
Copy link

@odony Your PR should do the trick. Thanks.

@sylnsr
Copy link

sylnsr commented Apr 27, 2018

All you need to do is create your own image with the correct version of the client tools. For example, I am using PG 9.6 and solved it by simply adding this to my base image: https://github.com/idazco/odoo-docker-ez/blob/master/10/Dockerfile#L83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed the bug was confirmed by testers
Projects
None yet
Development

No branches or pull requests

10 participants