0

I can't backup odoo 12 database, i use postgres 10 and docker containers.error:

Database backup error: Postgres subprocess ('/usr/bin/pg_dump', '--no-owner', '--file=/tmp/tmpgoyjsd3i/dump.sql', 'odoo') error 1
Veikko
  • 3,372
  • 2
  • 21
  • 31
omar marouani
  • 103
  • 1
  • 9

2 Answers2

1

This error occurs if you have a different version of Postgresql client (the version on Odoo server) and server (the version on your database server). If you are using the Odoo "official" Docker image or image based on that, e.g. veivaa/odoo image, it is based on debian:stretch version and it has Postgresql version 9.6 as default client. With this setup you will have a mismatch: client v9.6 connecting to server v10. It will result in the error you are getting.

To solve this you have to install same version on client and server. You can either downgrade your Postgres server to 9.6, or upgrade Postgres client in your Odoo Docker container to 10. You can test this by doing the client upgrade manually. docker exec -ti -u 0 yourodoocontainername bash to the Odoo container and executing these commands inside the Odoo container:

apt-get update
echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' >  /etc/apt/sources.list.d/pgdg.list
yes Y | apt-get install wget
yes Y | apt-get install gnupg
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
yes Y | apt-get install postgresql-client-10

You need to have root permissions in the container to run these. After this install you can exit from exec and restart your container with docker restart yourodoocontainername. Make sure you have persistent storage used for Odoo data so that you don't lose your filestore. After these steps you are able to do backups and restores with Odoo web interface.

You can check your Postgresql client version with psql --version command. The expected result with version 9.6 is psql (PostgreSQL) 9.6.10 and with version 10 psql (PostgreSQL) 10.6 (Debian 10.6-1.pgdg90+1).

The exec method is good for testing but not good for permanent use because it involves manual steps. You should build your Docker images with the right version by modifying your Dockerfile.

Veikko
  • 3,372
  • 2
  • 21
  • 31
  • i have this error after last command : root@4de61dbd92d0:/# yes Y | apt-get install postgresql-client-10 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package postgresql-client-10 root@4de61dbd92d0:/# – omar marouani Jan 03 '19 at 18:42
  • I can successfully update postgresql with this script on both odoo:12.0 and veivaa/odoo:12.0-20190101. I updated the script in answer slightly to prevent apt-get without "yes Y" from stopping the script if you copy all the rows via clipboard. The old version worked but required commands separately. – Veikko Jan 03 '19 at 20:31
  • What docker host system are you using (windows, mac, linux)? I remember having similar problems with dns name resolution when using Docker for Windows. Now I tested on mac and linux. – Veikko Jan 03 '19 at 20:34
  • i'm using system linux: ubuntu 18.04 LTS – omar marouani Jan 04 '19 at 08:42
  • how can i upgrade container postgres from version 10 to 9.6 or from version 11 to version 9.6 using docker exec in container postgres ? – omar marouani Jan 04 '19 at 08:44
  • Postgres does not support downgrading in-place (keeping persistent data volume and replacing the postgres container with other version). You can stll backup your database with pg_dump and restore it to the older version. This should work between versions when done in plain text format. See https://dba.stackexchange.com/questions/51874/pg-dump-custom-format-between-postgres-versions – Veikko Jan 04 '19 at 15:31
  • thank you, but i have error after commands: `docker exec -it -u root od_11 bash -c "pg_dump odoo >db.sql"` the error is: `pg_dump: [archiver (db)] connection to database "odoo" failed: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? ` even though i have odoo as the database name by consulting [@ip:port/web/databse/manager] – omar marouani Jan 04 '19 at 17:35
  • Run pg_dump in your postgres container. You would get the same error that you have referenced in original question in Odoo container because the versions do not match. – Veikko Jan 04 '19 at 17:46
0

I also experience this error. It is because your odoo docker image has a different version of Postgresql than the odoo database PostgreSQL image. please make sure that both have the same version.

  • Steps

docker exec -ti -u 0 yourodoocontainername bash

psql --version

the above will give you the version of PostgreSQL in the odoo container

docker exec -ti -u 0 yourodoocontainername bash

 psql --version

the above will give you the version of the PostgreSQL image

if the above two versions are different please use the following commands.

apt-get update
echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' >  /etc/apt/sources.list.d/pgdg.list
yes Y | apt-get install wget
yes Y | apt-get install gnupg
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update

yes Y | apt-get install postgresql-client-{virsion of your PostgreSQL image eg, 12 )