ODOO12 备份数据库.zip格式时报错,两种格式还原数据库报错

问题

.zip 格式备份数据库报错

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

恢复数据库报错

Database restore error: Postgres subprocess ('/usr/bin/pg_restore', '--dbname=XXX', '--no-owner', '/tmp/tmpb128rose') error 1

相似问题的贴子 https://github.com/odoo/docker/issues/234


原因

The backup feature of Odoo uses the postgresql-client. As a consequence,
if a database server newer than the client is used, the backup may fail.

翻译:Odoo的备份功能使用postgresql-client。
     因此,如果数据库服务器使用的postgresql-client比客户机更新,则备份可能会失败。

也就是说用来备份的主机(安装odoo程序的主机)的 postgresql-client 版本必须 >= 数据库服务器使用的版本。

解法

1. 登陆数据库后,即可看到版本的对比,如图:
psql -h databasehostname -U user postgres

版本的对比1

2. 在备份主机上安装 postgresql-client ,且版本 >= 数据库服务器使用的版本。
我的操作系统是Ubuntu 16.04.1 (Xenial) ,到Postgresql官网找到了源,按官方指示,创建源文件及添加了对应的条目,然后更新软件列表,安装 postgresql-clinet-10 (这个是10.9,高于数据库服务器版本) https://www.postgresql.org/download/linux/ubuntu/
下面为操作命令:
touch /etc/apt/sources.list.d/pgdg.list
vi /etc/apt/sources.list.d/pgdg.list

deb http://apt.postgresql.org/pub/repos/apt/xenial-pgdg main  #写入文件后保存退出

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-client-10

版本的对比2

此时不需要其它操作,再次去备份.zip 格式,成功了! 还原,成功了!


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容