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

Database backup #49

Closed
eino-makitalo opened this issue Jan 15, 2016 · 17 comments
Closed

Database backup #49

eino-makitalo opened this issue Jan 15, 2016 · 17 comments

Comments

@eino-makitalo
Copy link

When using login page database backup you get error...
Database backup error: Postgres subprocess ('/usr/bin/pg_dump', '--no-owner', '--file=/tmp/tmpFL6pNy/dump.sql', u'mydbname') error 1

@aetna-softwares
Copy link

I had the same problem and it apears to be a version conflict between postgresql client in odoo and in postgresql server version.

If you get the version 9 of postgresql as described in the documentation, it will fetch you the version 9.5 but odoo image used version 9.4 which is not compatible.

you have to use version 9.4 of postgresql server image
(bad news is that your data created with 9.5 are not compatible with 9.4)

@pilhokim
Copy link

pilhokim commented Feb 5, 2016

You can directly bash into the postgres container and export the data out.

For instance,

$docker exec -i -t yourpostgrescontainerid bash

Then within Postgre bash, run pg_dumpall (or use pg_dump for selected db export).

root@yourpostgrescontainerid $pg_dumpall -U odoo | gzip -c > odoo_backup.out.gz
exit

Now copy out the backup file to your host
$docker cp yourpostgrescontainerid :/root/odoo_backup.out.gz yourbackupdirectory

After you would want to go back to Postgres bash and remove the backup file there.

@eino-makitalo
Copy link
Author

Thx. Yes, I can backup using docker utils indeed. I also can backup when connecting to postgres docker instance through using database instance private address ...docker inspect db | grep "IPAddress" and connecting to port 5432 using pg_dump or pg_admin, but it seems that Odoo's own tool is not working. - So this is a bug report concerning faulty backup operation of Odoo when using this docker image.

@tkontogi
Copy link

Not sure if my question relates to this bug.

What about backing up a DB from a hosted production odoo installation and restoring it into a local dockerized odoo?

Tried that with odoo 8 container, but it fails.

image

This is the error I get and immediately reverts to the main manager's page.

Any idea?

Appreciated.

@tkontogi
Copy link

So packet loss is the root cause right? If the patch cords are loosing packets, then it is a no go for all the setup.

@helgetan
Copy link

i'm having the same issue, has anyone checked @aetna-softwares version conflict proposal?

@tkontogi
Copy link

I tried to but I am always gettin the following error:

image

I am not sure if the error is related to our problem.

@tkontogi
Copy link

tkontogi commented Mar 4, 2016

OK... I have removed all images and start over again.. The import finished smoothly.
I am using odoo:8 and postgresql:9.4

One thing that does not work is the mapping of modules.

My images storage is '~/My-VMs/docker/'

In there I have '~/My-VMs/docker/maps/' for directories that will be mapped.

So I run

'docker run -v ~/My-Virtual-Machines/docker/maps/addons:/mnt/extra-addons -p 8069:8069 --name odoo --link db:db -t odoo:8'

But the modules are not accessible.

Then 'docker exec -it f76e52af0065 /bin/bash'

Then:
f76e52af0065:/$ ls -l /mnt/extra-addons/
ls: cannot open directory /mnt/extra-addons/: Permission denied
f76e52af0065:/$

Any ideas?

I used 'nsenter --target 5670 --mount --uts --net --ipc --pid' to change the ownership of /mnt/extra-addons in the image, but the results was the same.

So the solution regarding the images versions looks correct, but the mapping does not work for addons.

Open to any suggestions.

@tkontogi
Copy link

tkontogi commented Mar 5, 2016

AND IT WORKS

SElinux was the issue.

As of docker 1.7 there is a Z option following the mapping declaration, that automatically lables the hosts's to be mapped directory with the correct context for the container.

So.

To revise:

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

Observe the :9.4 (colon 9.4) at the end of the postgres image version.

docker run -v /full/path/to/hosts/dir:/mnt/extra-addons:Z -p 8069:8069 --name odoo --link db:db -t odoo:8

Observe the :Z (colon Z) at the end of the -v declaration.

In case you are using the image to experiment with you actual DBs backup, make sure that the host's path, has all the modules as in your production server.

I just restored into the docker image, my production DB running on a hosted server on the Internet.

Full functionality.

Regards,

Theo

@andersonkyle
Copy link

What is the recommended method for using the Odoo 9 Docker image with Postgres 9.5? The postgresql client included with the Odoo 9 image is for version 9.4 and doesn't support certain operations such as backup (e.g. pg_dump). How should we overcome this and bake it into a Dockerfile?

@andersonkyle
Copy link

@fpodoo Can you address my previous question?

@blaggacao
Copy link

blaggacao commented Jun 5, 2016

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...

@elicoidal
Copy link

this might help: odoo/odoo#12275 (comment)

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

Bottom-line: please use the 9.4 version of the postgres docker image with Odoo 9. We're updating the docker image documentation to make the version tag explicit, so you'd run it this way:
$ docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db postgres:9.4

@odony
Copy link
Contributor

odony commented Jun 7, 2016

@kanderson450 if you want to use PG 9.5 with the official Odoo 9 docker image you should simply add a layer on top of it to install the postgresql-client-9.5 package. You can get inspiration from the official postgres dockerfile, which is also based on debian:jessie, like the odoo one. Just install postgresql-client instead of the server.

@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
None yet
Projects
None yet
Development

No branches or pull requests