简体   繁体   English

dbbackup 指定使用哪个 pg_dump

[英]dbbackup specify which pg_dump to use

When calling打电话时

from django.core.management import call_command
call_command('dbbackup', compress=True, interactive=False)

I get:我得到:

CommandConnectorError: Error running:  pg_dump xxx --host=localhost --port=xxx --username=xxx --no-password --clean 
pg_dump: server version: 9.6.5; pg_dump version: 8.4.20
pg_dump: aborting because of server version mismatch

I'm using a non-root installation of PostgreSQL (version 9.6.5 ) as backend for a django application.我正在使用 PostgreSQL(版本9.6.5 )的非 root 安装作为 django 应用程序的后端。 (Used this tutorial for the installation.) (使用教程进行安装。)

There is also a postgreSQL installation in the machine (version 8.4.20 ).机器中还有一个 postgreSQL 安装(版本8.4.20 )。

Before I switched to the non-root installation, everything worked flawlessly.在我切换到非 root 安装之前,一切都完美无缺。 My guess is that the pg_dump called in dbbackup is still the one from the root installation.我的猜测是dbbackup调用的pg_dump仍然是 root 安装中的那个。

How can one specify which pg_dump to use?如何指定使用哪个 pg_dump ?

If you have made a non-root installation of postgreSQL, say with the user nonrootuser , then you should find psql as well as pg_dump for this installation under /home/nonrootuser/postgres/bin/ .如果您对 postgreSQL 进行了非 root 安装,比如使用用户nonrootuser ,那么您应该在/home/nonrootuser/postgres/bin/下找到此安装的psqlpg_dump This is the pg_dump you want to use.这是您要使用的pg_dump

Dbbackup allows you to specify the connector it uses to create the backup. Dbbackup 允许您指定用于创建备份的连接器。 In particular it allows you to specify the dump command ( DUMP_CMD ).特别是它允许您指定转储命令( DUMP_CMD )。 To specify the connector, add the following block to your settings.py:要指定连接器,请将以下块添加到您的 settings.py:

import os  # if not yet imported
DBBACKUP_CONNECTORS = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'xxx',
        'USER': 'xxx',
        'PASSWORD': 'xxx',
        'HOST': 'xxx',
        'PORT': 'xxx',
        'DUMP_CMD': os.path.join(
            os.environ["HOME"],
            'nonrootuser',
            'bin',
            'pg_dump'
            )
        }
    }

Replace the xxx with your specific values.xxx替换为您的特定值。

Hope that helps!希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM